From 258e1b92ebbfdebefabc120969ab87c3d8b75c3d Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sun, 15 Jun 2014 03:50:12 +0200 Subject: old c,cc examples --- c,cc/cast.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 c,cc/cast.cc (limited to 'c,cc/cast.cc') diff --git a/c,cc/cast.cc b/c,cc/cast.cc new file mode 100644 index 0000000..2e84a64 --- /dev/null +++ b/c,cc/cast.cc @@ -0,0 +1,27 @@ +#include + +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(new Ba); + cout << "-" << endl; + x->q(); + x->p(); +} + -- cgit v1.2.3