diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-14 16:46:27 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-14 16:46:27 +0200 |
commit | 26c490f404731d053a6205719b6246502c07b449 (patch) | |
tree | 3aa721098f1251dfbf2249ecd2736434c13b1d48 /ccc/cast.cc |
init
Diffstat (limited to 'ccc/cast.cc')
-rw-r--r-- | ccc/cast.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ccc/cast.cc b/ccc/cast.cc new file mode 100644 index 0000000..2e84a64 --- /dev/null +++ b/ccc/cast.cc @@ -0,0 +1,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(); +} + |