Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Parent
  6. {
  7. public:
  8. Parent() { /*cout << "Parent::Parent()" << "\n";*/ }
  9. virtual ~Parent() { /*cout << "Parent::~Parent()" << "\n";*/ }
  10.  
  11. virtual int f() { cout << "Parent::f()\n"; return 0; }
  12. virtual int f() const { cout << "Parent::f() const\n"; return 0; }
  13. };
  14.  
  15. class Child : public Parent
  16. {
  17. public:
  18. void y() {};
  19.  
  20. Child() { /*cout << "Child::Child()" << "\n";*/ }
  21. ~Child() { /*cout << "Child::~Child()" << "\n";*/ }
  22.  
  23. virtual int f() { cout << "Parent::f()\n"; return 0; }
  24. virtual int f() const { cout << "Parent::f() const\n"; return 0; }
  25. };
  26.  
  27. int main (int argc, char* argv[])
  28. {
  29. {
  30. Parent* pParentIsChild = new Child();
  31.  
  32. pParentIsChild->f();
  33.  
  34. delete pParentIsChild;
  35. }
  36.  
  37. // ---
  38.  
  39. char asd; cin >> asd;
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement