Vidyalelo
C++ Programming · Q75

Constructors and Destructors in C++

Programming · C++ Programming · question 75

Q75

What will be the output of the following C++ code? #include using namespace std; class A A() cout<<"A's Constructor called "; friend class B; ; class B public: A a; B() cout<"B's constructor called "; ; int main(int argc, char const *argv[]) B b; return 0;

A.
A's Constructor called
B's constructor called
Answer
B.
B's Constructor called
A's constructor called
C.
Error
D.
Segmentation fault

Answer: Option A

Solution

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