Class Composition in C++

What would the output of above c++ code be? \text{What would the output of above c++ code be?}

ABC~A~B~C ~C~B~AABC ABC~C~B~A CBA~A~B~C

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Harikrishna Nair
Nov 19, 2015

We should start from int main() as soon as object of class C is created the compiler goes to class C. There object of class B is created so it goes to class B. There object of class A is created so it goes to class A. Now one by one it starts with the execution of constructor of class A then B and then C. But the destructor is always called opposite to the order of call given to the constructors. So final output will be ABC~C~B~A

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...