I have following code
#include <iostream>
using namespace std;
class Base {
private:
Base() {
cout<<"Base ctor has been called "<<endl;
};
public:
int a;
};
class Derived: public Base {
};
int main() {
Base* b1;
Derived d1();
cout<<d1;
return 0;
}
I am not sure how the derived class object d1 is created in the above example. The code compiles and run without any error. What type of constructor is getting called while creating Derived d1(); ? and why output of the cout<<d1; is coming as 1? Would the instance of Derived have int a of base class? Thanks for all the help!