Vidyalelo
C++ Programming · Q85

Introduction to C++

Programming · C++ Programming · question 85

Q85

What will be the output of the following C++ code? #include using namespace std; class A private: int x; public: A(int _x) x = _x; int get() return x; ; class B static A a; public: static int get() return a.get(); ; int main(void) B b; cout << b.get(); return 0;

A.
Garbage value
B.
Compile-time Error
Answer
C.
Run-time Error
D.
Nothing is printed

Answer: Option B

Solution

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