I was learning about inheritance. If we have used private access specifier in base class then it is not accessible in derived class. But I have a doubt regarding this.
#include<bits/stdc++.h>
using namespace std;
class A
{
private:
int a;
int b;
int c;
public:
int d;
void print()
{
cout<<"Inside A Print()"<<endl;
}
};
class B: public A
{
private:
int a1,b1,c1;
public:
B()
{
}
void print()
{
cout<<"Inside B Print()"<<endl;
}
};
int main()
{
B obj;
cout<<sizeof(obj)<<endl;
return 0;
}
Since I have used public access specifier during inheriting class A. Since we know that private member of base class is not accessible at all. So output of above code should be: 16. But compiler giving the output as 28. Can anyone explain this?