I tried this :-
code suggests me, that even the private members of the base class are actually inherited and present in derived objects <sizeof>, but accessibility only restricts us to which members i can actually access from my derived object or infact in my derived classCode:#include<iostream> using namespace std; class A { int x; }; class B:private A { int y; public: void foo() { cout<<x; // error } }; int main() { A a; B b; cout<<sizeof(a); // 4 cout<<sizeof(b); // 8 b.foo(); }
I would appreciated any confirmation