Question on virtual inheritance
  Home FAQ Contact Sign in
comp.lang.c++ only
 
Advanced search
POPULAR GROUPS

more...

 Up
Question on virtual inheritance         

Group: comp.lang.c++ · Group Profile
Author: ambarish.mitra
Date: Apr 23, 2008 23:55

#include

class base {
public: virtual void f() {}
};

class derived: public virtual base {
};

int main()
{
std::cout << "size of base = " << sizeof(base) <<
std::endl; /* =4 . This is Okay.*/
std::cout << "size of derived = " << sizeof(derived) <<
std:endl; /* 4 or 8 */
}

In MS environment (Visual Studio 6/7), the output is coming as 8,
whereas in g++ compiler (g++ 3.4.5), the output is coming as 4.

Can any1 tell how the internals work out for virtual inheritance in
these 2 compilers? (I hv checked that size of pointer =4 in both
systems).
2 Comments
diggit! del.icio.us! reddit!

RELATED THREADS
SubjectArticles qty Group
Quer sexo real, virtual? - It wants real, virtual sex?soc.culture.brazil ·