C++ | Static Keyword | Question 5
Test::count = 0;
cout << Test::count <<
(A) Compiler Error
(B) 4 4 4 4
(C) 1 1 1 1
(D) 1 2 3 4
Explanation: Static members are accessible in non-static functions, so no problem with accessing count in fun().
Also, note that fun() returns the same object by reference.
Quiz of this Question
Want to learn from the best curated videos and practice problems, check out the C Foundation Course
for Basic to Advanced C.