Chris Lattner wrote:
Tiago Stein wrote:
class A{}; class B :public A{}; class C: public A{ int g; }; class D: public B, public C { unsigned int foo; }; Why sizeof class D is 12? Should not be 8?
no, there are two.
But is not only a single A present at D?
> If I wanted separate A for each
side of inheritance shouldn't I use virtual inheritance?no you'd use that when you wanted one instance
> When I Use it..
yes, that is what the standard says.it adds even more size to the final class, so that I have more space used than is necessary to keep each onde witha separet adress.
you do not understand correctly.So if I understand correctly.. yhis is done to keep B and A with different addresses.. and not B::A and C::A ?
this is now no longer a g++ specific question, but one about C++. A C++ newsgroup would be appropriate to explore the whys of this requirement.
nathan
-- Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC nathan@xxxxxxxxxxxxxxxx :: http://www.planetfall.pwp.blueyonder.co.uk