Answer to Question #239534 in C++ for unique

Question #239534

Consider following code and state the order of execution constructors and order

of execution of destructors.

class C: public A, virtual public B

{ public:

C( ):A( ),B( )

{

cout<<”c class constructor”;

}

};


1
Expert's answer
2021-09-22T23:43:56-0400

First will be executed constructor of the B class, then the constructor of the A class, then the constructor of the C class.

The order of the execution of the destructors will be the reversal: first will be executed the destructor of the C class, then the destructor of the A class and, finally, the destructor of the B class.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS