1 #include <stdio.h> 2 #include <stdint.h> 3 4 class A 5 { 6 public: 7 A () : m_pad ('c') {} 8 9 virtual ~A () {} 10 11 virtual const char * a() 12 { 13 return __PRETTY_FUNCTION__; 14 } 15 16 virtual const char * b() 17 { 18 return __PRETTY_FUNCTION__; 19 } 20 21 virtual const char * c() 22 { 23 return __PRETTY_FUNCTION__; 24 } 25 protected: 26 char m_pad; 27 }; 28 29 class AA 30 { 31 public: 32 AA () : m_pad('A') {} 33 virtual ~AA () {} 34 35 virtual const char * aa() 36 { 37 return __PRETTY_FUNCTION__; 38 } 39 40 protected: 41 char m_pad; 42 }; 43 44 class B : virtual public A, public AA 45 { 46 public: 47 B () : m_pad ('c') {} 48 49 virtual ~B () {} 50 51 virtual const char * a() 52 { 53 return __PRETTY_FUNCTION__; 54 } 55 56 virtual const char * b() 57 { 58 return __PRETTY_FUNCTION__; 59 } 60 protected: 61 char m_pad; 62 }; 63 64 class C : public B, virtual public A 65 { 66 public: 67 C () : m_pad ('c') {} 68 69 virtual ~C () {} 70 71 virtual const char * a() 72 { 73 return __PRETTY_FUNCTION__; 74 } 75 protected: 76 char m_pad; 77 }; 78 79 int main (int argc, char const *argv[], char const *envp[]) 80 { 81 A *a_as_A = new A(); 82 B *b_as_B = new B(); 83 A *b_as_A = b_as_B; 84 C *c_as_C = new C(); 85 A *c_as_A = c_as_C; 86 87 // Set first breakpoint here. 88 // then evaluate: 89 // expression a_as_A->a() 90 // expression a_as_A->b() 91 // expression a_as_A->c() 92 // expression b_as_A->a() 93 // expression b_as_A->b() 94 // expression b_as_A->c() 95 // expression b_as_B->aa() 96 // expression c_as_A->a() 97 // expression c_as_A->b() 98 // expression c_as_A->c() 99 // expression c_as_C->aa() 100 printf ("a_as_A->a() = '%s'\n", a_as_A->a()); 101 printf ("a_as_A->b() = '%s'\n", a_as_A->b()); 102 printf ("a_as_A->c() = '%s'\n", a_as_A->c()); 103 printf ("b_as_A->a() = '%s'\n", b_as_A->a()); 104 printf ("b_as_A->b() = '%s'\n", b_as_A->b()); 105 printf ("b_as_A->c() = '%s'\n", b_as_A->c()); 106 printf ("b_as_B->aa() = '%s'\n", b_as_B->aa()); 107 printf ("c_as_A->a() = '%s'\n", c_as_A->a()); 108 printf ("c_as_A->b() = '%s'\n", c_as_A->b()); 109 printf ("c_as_A->c() = '%s'\n", c_as_A->c()); 110 printf ("c_as_C->aa() = '%s'\n", c_as_C->aa()); 111 return 0; 112 } 113