Multiple choice technology programming languages

#include const int SIZE = 5; struct tester { int array[SIZE]; enum { SIZE = 3 }; void size() { std::cout << sizeof(array) / sizeof(int); } }; int main(int argc, char** argv) { tester t; t.size(); return 0; }

  1. 5

  2. 3

  3. 0

  4. undefined

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The array member of the struct is declared using the global constant SIZE which equals 5. Inside the member function size, sizeof(array) evaluates to 5 times the size of an integer, and dividing by sizeof(int) yields 5. The inner enum declaration defining SIZE as 3 hides the global constant in some contexts, but does not affect the array size determined at class scope definition.