What will be printed out as a result of the following code's execution?
#include <iostream>
class A
{
public:
A(void){std::cout << "A";}
~A(void){std::cout << "a";}
};
class B : public A
{
public:
B(void){std::cout << "B";}
~B(void){std::cout << "b";}
};
int main(void)
{
B b;
return 0;
}
When creating an object the base class constructor is called first and the one to which the object belongs - only after that. The procedure for destructors call is the opposite - destructor of the class to which an object belongs will be called first, and that of the base class - after that.
Login in to like
Login in to comment