using namespace std;
class Gparent{
public:
int house;
Gparent(){
house = 1;
cout<<house<<endl;
}
~Gparent(){
cout<<"Gparent got killed"<<endl;
}
};
class Parent: private Gparent{
public:
Parent(){
Gparent::house=2;
cout<<Gparent::house<<endl;
}
~Parent(){
cout<<"Parent got kiled"<<endl;
}
};
int main(){
Gparent g;
g.house=100;
}
output: 1 Gparent got killed
why the output is not 100? I can understand the object creation but bit confused with the initialization part.Could someone help me to understand the concept?