summaryrefslogtreecommitdiff
path: root/tests/exec/multi_virt.cpp
blob: c0950b7aba07bf97d44c0c86befcde1f2ff77ecc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>

class A { public : int a; virtual void fa();};
class B { public : int b; virtual void fb(); virtual void h();};

class C : public A, public B { public : int c; virtual void fc();};

class D { public : int d; virtual void fd(); virtual void h();};
class E : public C, public D { public : int e; virtual void fb(); virtual void fd(); virtual void h();};

void B::fb() {std::cout << "B::fb";}
void E::fb() {std::cout << "E::fb";}
void A::fa() {std::cout << "A::fa";}
void D::fd() {std::cout << "D::fd";}
void E::fd() {std::cout << "E::fd";}
void C::fc() {std::cout << "E::fc";}

void E::h() {std::cout << "E::h";}
void B::h() {std::cout << "B::h";}
void D::h() {std::cout << "D::h";}


int main() {
  
  E* cp = new E();
  cp->h();
  std::cout << "\n";
  cp->fd();
  std::cout << "\n";

  D* dp = new E() ;
  dp->h();
  std::cout << "\n";
  dp->fd();
  std::cout << "\n";

  A* ap = new C() ;
  ap->fa();

  std::cout << "\n";

  return 0;
}