summaryrefslogtreecommitdiff
path: root/c,cc/cast.cc
blob: 2e84a643ad8e9ea246cebeeb572797d96aa85dea (plain)
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
#include <iostream>

using namespace std;


struct A {
  virtual void p() { cout << "A" << endl; }
  void q() { cout << "q" << endl; }
};

struct Ba : public A {
  void p() { cout << "Ba" << endl; }
};

struct Bb : public A {
  void p() { cout << "Bb" << endl; }
};

int main(void)
{
  A* x = new A;
  x = dynamic_cast<Ba*>(new Ba);
  cout << "-" << endl;
  x->q();
  x->p();
}