// inheritence experiment
#include"stdafx.h"
#include<iostream>
using namespace std;
class base
{
private:
int i;
};
class derived: public base
{
private:
int j;
};
int main()
{
cout << endl << sizeof(derived) << endl << sizeof(base);
derived o1;
base o2;
cout << endl << sizeof(o1) << endl << sizeof(o2);
}
I'm getting this output:
8
4
8
4
why's that so? private data members of a base class aren't inherited into the derived class, so why I am getting 8 bytes for both, the size of derived and o1 ?