JoelKatz

Untitled

Nov 20th, 2013
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class Parent
  4. {
  5. public:
  6.     Parent() { ; }
  7.     virtual void function() { std::cout << "Parent::function" << std::endl;; }
  8. };
  9.  
  10. class Child : public Parent
  11. {
  12. public:
  13.     Child() { ; }
  14.     void function() { std::cout << "Child::function" << std::endl; }
  15. };
  16.  
  17. class Test
  18. {
  19. public:
  20.      Test(Parent& c) { c.function(); }
  21. };
  22.  
  23. int main()
  24. {
  25.     Child c;
  26.     Parent& p = c;
  27.     Test t(p);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment