[Code]

 

#include <stdio.h>

 

//

// Each class has his own 256 bytes buffer.

//

class A  { char a[256]; };

class B  { char b[256]; };

class C  { char c[256]; };

class D  { char d[256]; };

class E  { char d[256]; };

 

//

// Write pointers.

//

void print(A* a, B* b, C* c, D* d, E* e)

{

  printf("a=%p\n", a);

  printf("b=%p\n", b);

  printf("c=%p\n", c);

  printf("d=%p\n", d);

  printf("e=%p\n", e);

}

 

//

// Class Z is derived from all above classes.

//

class Z : A, B, C, D, E

{

public:

  void foo()

  {

    //

    // Call print function(pass this pointers).

    //

    print(this, this, this, this, this);

  }

};

 

void main()

{

  Z z;

  z.foo(); // What is result of print output? all the same? or else?

}

 

 

[Result]

 

a=0012FA28

b=0012FB28

c=0012FC28

d=0012FD28

e=0012FE28

Each pointer is different. It depends on parent class sizes.