This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Double abstract class Inheritance concern.
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Tiago Stein <tiago at lisha dot ufsc dot br>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 29 Mar 2004 14:14:30 +0100
- Subject: Re: Double abstract class Inheritance concern.
- Organization: Codesourcery LLC
- References: <Pine.LNX.4.44.0403281937360.23968-100000@nondot.org> <4067D6DD.1060607@codesourcery.com> <32820.150.162.62.2.1080565335.squirrel@www.lisha.ufsc.br>
Tiago Stein wrote:
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?
But is not only a single A present at D?
no, there are two.
> 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..
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.
yes, that is what the standard says.
So if I understand correctly.. yhis is done to keep B and A with different
addresses.. and not B::A and C::A ?
you do not understand correctly.
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@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk