A
ambarish.mitra
#include <iostream>
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).
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).