Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MyBaseClass* a = new MyBaseclass();
- a->BaseMethod(); // Call method using -> operator (dereference and call)
- MyBaseClass* b = new MyDerivedClass();
- b->DerivedMethod(); // Error: MyBaseClass has no such method
- // Proper C++-Style casting.
- MyDerivedClass* c = dynamic_cast<MyDerivedClass*>(b);
- // Shortcut to the above, does not do the type test.
- // MyDerivedClass* c = (MyDerivedClass*)b;
- c->DerivedMethod(); // Ok
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement