What will be printed out (in what order will the destructors be called)?
#include <iostream>
using namespace std;
     
class A {
    public:
    A () {}
    ~A() { cout << "~A";}
};
     
class B : public A {
    public:
    B () {}
    ~B () { cout << "~B"; }
};
     
int main () {
    A *b = new B ();
    delete b;
    return 0;
}

Follow CodeGalaxy

Mobile Beta

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