Vidyalelo
C++ Programming · Q166

Classes and Objects in C++

Programming · C++ Programming · question 166

Q166

What will be the output of the following C++ code? #include #include using namespace std; class B int b; public: B() B(int i) b = i; int show() return b; ; class C B b; public: C(int i) b = B(i); friend void show() C c(10); cout<<"value of b is: "<<c.b.show()<<endl; ; int main(int argc, char const *argv[]) C c(1); c.show(); return 0;

A.
value of b is: 10
B.
value of b is: 12345435
C.
error
Answer
D.
segmentation fault

Answer: Option C

Solution

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