Question #239533

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”;

}

};


Expert's answer

class C: public A, virtual public B
{ public:
C( ):A( ),B( )
{
cout<<"c class constructor";
}
};
/*
Answer:
A constructor is a special type of class method that is automatically called
 when an object of the same class is created.
In this code snippet, no class objects have been created. 
Consequently, no constructors or destructors will be called.
*/
LATEST TUTORIALS
APPROVED BY CLIENTS