Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class Parent
- {
- public:
- Parent() { ; }
- virtual void function() { std::cout << "Parent::function" << std::endl;; }
- };
- class Child : public Parent
- {
- public:
- Child() { ; }
- void function() { std::cout << "Child::function" << std::endl; }
- };
- class Test
- {
- public:
- Test(Parent& c) { c.function(); }
- };
- int main()
- {
- Child c;
- Parent& p = c;
- Test t(p);
- }
Advertisement
Add Comment
Please, Sign In to add comment