View Single Post
Old Feb 4th, 2007, 12:23 PM   #1
sharadpro
Newbie
 
Join Date: Feb 2006
Location: India
Posts: 25
Rep Power: 0 sharadpro is on a distinguished road
Size of inherited class!

#include<iostream>
using namespace std;

class X
{
int x;
public:
int y;
protected:
int z;
};

class Y : public X
{
int a;
public:
int b;
protected:
int c;
};

int main()
{
cout<<sizeof(Y);
return 0;
}


According the output (24 on my machine) , even the variable x which was private in class X is being considered as a part of class Y?
Please explain!
sharadpro is offline   Reply With Quote