#include <stdio.h> class A { protected: int *a; public: A(int *p) : a(p) { fprintf(stdout, "A::A(int *)\n"); } ~A() { fprintf(stdout, "A::~A()\n"); } void pa() { fprintf(stdout, "&A::a = %x\n", &a); } }; class B : public virtual A { public: B(int *p) : A(p) {} void pb() { pa(); } }; template <int N = 2> class C : public B { protected: int c[N]; public: C() : A(c), B(c) { for (int i = 0; i < N; i++) c[i] = 1; } void pc() { pb(); for (int i = 0; i < N; i++) fprintf(stdout, "&C::c[%d] = %x\n", i, &c[i]); } }; C<> c; int main(void) { fprintf(stdout, "&c = %x, sizeof(C<>) = %d\n", &c, sizeof(C<>)); const int *cptr = (int *)(void *)&c; for (int i = 0; i < sizeof(C<>)/sizeof(int); i++) fprintf(stdout, "cptr[%d] = %x\n", i, cptr[i]); c.pc(); return 0; }