Virtual base class

Hello,

what is the size of object of Class child in following case?

class Parent
{

};
class Child : virtual public Parent
{

};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

class Parent
{

};
class Child : virtual public Parent
{

};

int main()
{
    std::cout << sizeof(Child) << '\n' ;
}


It is what it is.
thanx cire for reply.

yes you are right.

size become 4 byte(depend on compiler).

right?
Yes.

You might find some interesting reading here:
http://stackoverflow.com/questions/2038717/object-size-with-virtual
yes its because Child class contain one vptr. because its virtual base class inheritance.

So, what that vptr stored?
means whose address it store?

address of VTable for Parent class?
Hi cire,

waiting for reply...
Topic archived. No new replies allowed.