#include<iostream>
using namespace std;
int main(){
class c1{
public:
c1(){
cout<<"constructing c1";
}
};
class c2:private c1{
public:
c2(){
cout<<"constructing c2";
}
};
c2 inst1;
}
q1. Even when the access is private, why is the base's c'tor called for derived object?
i.e why is c1()
called even when class c1
is inherited as private?
q2. Here c1 is inherited, how can i prevent that from happening?