I'm currently taking a C++ course and we are learning about pointers. The following is an example my professor gave us.
int b[3][3]; //Assume integers and memory addresses are 4 bytes
cout << sizeof(b) << endl; // 36 bytes
cout << sizeof(b+0) << endl; // 4 bytes
cout << sizeof(*(b+0)) << endl; //12 bytes
I have 2 questions:
I tried the second one (
sizeof(b+0)
) and it gives me 8 instead? How come that is the case?Also I want to understand the logic behind the third one (
sizeof(*(b+0)
); is it 12 because it is the total of the first row? Since there are 3 ints and each int is 4 bytes thus it returns 12 bytes in total?
Any help is much appreciated!