This program

#include <iostream>

using std::cout;
using std::endl;

class A {int a;};

class B : public virtual A{};

int main(){
  cout << "sizeof B is " << sizeof(B) << endl;
  return 0;
}


produces following output:

sizeof B is 8

Why?

There are no virtual functions, so I thought there would be no
extra pointers (to vtable) needed either. But it doesn't seem to 
play out that way. 
What information does that pointer point to? Why is it neccesary? 
Can I avoid the generation of that extra pointer somehow, while still 
using virtual base classes?

-Samuli
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to