Vidyalelo
C++ Programming · Q103

Introduction to C++

Programming · C++ Programming · question 103

Q103

What will be the output of the following C++ code? #include using namespace std; class Test private: static int count; public: Test& fun(); ; int Test::count = 0; Test& Test::fun() Test::count++; cout << Test::count << " "; return *this; int main() Test t; t.fun().fun().fun().fun(); return 0;

A.
4 4 4 4
B.
1 2 3 4
Answer
C.
1 1 1 1
D.
0 1 2 3

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board