memory-address

Why is address of char data not displayed?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 00:17:05
问题 class Address { int i ; char b; string c; public: void showMap ( void ) ; }; void Address :: showMap ( void ) { cout << \"address of int :\" << &i << endl ; cout << \"address of char :\" << &b << endl ; cout << \"address of string :\" << &c << endl ; } The output is: address of int : something address of char : // nothing, blank area, that is nothing displayed address of string : something Why? Another interesting thing: if int, char, string is in public, then the output is ... int :

What exactly is the array name in c?

流过昼夜 提交于 2019-11-25 23:41:40
问题 I am having a tough time understanding the type and use of the name of the array in C. It might seems a long post but please bear with me. I understand that the following statement declares a to be of type int [] i.e array of integers . int a[30]; While a also points the first element of array and things like *(a+2) are valid. Thus, making a look like a pointer to an integer . But actually the types int [] and int* are different; while the former is an array type and later is a pointer to an