What will be printed out as a result of the following code execution?
#include "iostream"

using namespace std;
class A
{
public:
    A() {constr();}
    virtual ~A() {destr();}
    virtual void constr() const {;}
    virtual void destr()  const {;}
};

class B: virtual public A
{
public:
    B() {constr();}
    ~B() {destr();}
    void constr() const {cout << "B" ;}
    void destr()  const {cout << "~B";}
};

int main()
{
    A *a, *b;
    a = new A;
    b = new B;

    delete b;
    delete a;
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes