sizeof (..); Function
The int type outputs a result of type 4;double to 8;float type of 4;
int *i=null; Here the value of the variable i is 00000000, is an address, that is, NULL is a pointer with an address of 00000000, but the *i is not initialized, the direct output is an error;
Parameter passing:
#include <iostream>
using namespace Std;
Value passing
void Change1 (int n) {
cout<< "Value passing--function operation Address" <<&n<<endl; The copied address is displayed instead of the source address
n++;
}
Reference delivery
void Change2 (int & N) {
cout<< "Reference pass--function address" <<&n<<endl;
n++;
}
Pointer passing
void Change3 (int *n) {
cout<< "Pointer pass--function address" <<n<<endl;
*n=*n+1;
}
int main () {
int n=10;
cout<< "Address of the argument" <<&n<<endl;
Change1 (n);
cout<< "after Change1 () n=" <<n<<endl;
Change2 (n);
cout<< "after Change2 () n=" <<n<<endl;
Change3 (&n);
cout<< "after Change3 () n=" <<n<<endl;
return true;
}
Results Analysis:
int n=10;
Address of the actual parameter 0019ff3c
Value passing--function operation address 0019FEEC
After Change1 () n=10
Reference passing--function action address 0019ff3c
After Change2 () n=11
Pointer passing--function operation address 0019ff3c
After Change3 () n=12
When an argument is passed, a variable in the main function of the address is reassigned and the variable in the calling function is not an address when the calling function changes the value in the main function does not change, whereas reference passing and pointer passing are operations on the same address.
When an array is passed as a parameter, it is similar to a pointer to passing the first address of the array to the function, but modifying the value in the calling function alters the value in the main function.
Data:
struct Type_name {
Member_type1 member_name1;
member_type2 member_name2;
Member_type3 member_name3;
.. } object_names;
Type_name is the name of the struct type
Class:
Access modifiers:
Public: Members can be accessed outside of the class
Private: Members of the class cannot be accessed outside the class;
Protected: Members of a class cannot be accessed outside the class, but are accessible on derived classes of that class.
This article is from the "9247012" blog, please be sure to keep this source http://9257012.blog.51cto.com/9247012/1950928
C + + Notes