Size of the Class


Question1: I know the size of the Empty class is 1. Why is it so. Please explain it in details.

Question2:

class Base
{
private:
int i;
public:
Base()
{
}

~Base()
{
}
};

class Dervied1: virtual public Base
{
public:
Dervied1()
{
}

~Dervied1()
{
}

};


class Dervied2: virtual public Base
{
public:
Dervied2()
{
}
~Dervied2()
{
}
};

class Dervied3: public Dervied1, Dervied2
{
public:
Dervied3()
{
}
~Dervied3()
{
}
};

My question is
1. what is the size of Dervied2 and Dervied3 Class if you do not use the virtual keyword while inheriting?
2. what is the size of Dervied2 and Dervied3 Class if you use the virtual keyword while inheriting?
Question 1: because you can't have a type with a smaller size than a byte
http://www2.research.att.com/~bs/bs_faq2.html#sizeof-empty
( Please use [code][/code] tags )
Topic archived. No new replies allowed.