Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class B{
- public:
- virtual void call() { cout<<"Bn"; };
- };
- class D: public B{
- public:
- void call() { cout<<"Dn"; }
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- B b;
- D d;
- b.call(); // output is "B"
- d.call(); // output is "D"
- B* obj = &d;
- obj->call(); // output is "D"
- return 0;
- }
- Base * obj = &DerivedA;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement