summaryrefslogtreecommitdiff
path: root/tests/exec/inheritance1.cpp
blob: 8a2c1e7eed38c6bddc38184b29b9a3f90d134151 (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
#include <iostream>

class A {
public:
  virtual void f();
};

class B : public A {
public:
  void f();
};

void A::f() {
  std::cout << "this is A::f" << "\n";
}

void B::f() {
  std::cout << "this is B::f" << "\n";
}

int main() {
  A a;
  a.f();
  B b;
  b.f();
  A *x = &b;
  x->f();
  x = &a;
  x->f();
}