Can anyone explain to me the constructor calls, in the following code. How is the constructor of abstract class called, when there exist no object for it but only a pointer to the derived class. Is an instance of it created to hold the vtable ?
#include <iostream>
using namespace std;
class pure_virtual {
public:
pure_virtual() {
cout << "Virtul class constructor called !" << endl;
}
virtual void show()=0;
};
class inherit: public pure_virtual {
public:
inherit() {
cout << "Derived class constructor called !" << endl;
}
void show() {
cout <<"stub";
}
};
main() {
pure_virtual *ptr;
inherit temp;
ptr = &temp;
ptr->show();
}