Advertisement
obernardovieira

class derivative of one class and base of another

Jan 13th, 2016
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. class b1
  2. {
  3. public:
  4.     b1() { }
  5.     ~b1() { }
  6.     virtual void saida() { cout << "b1" << endl; }
  7. };
  8.  
  9. class base : public b1
  10. {
  11. public:
  12.     base() { }
  13.     ~base() { }
  14.     virtual void saida() { cout << "base" << endl; }
  15. };
  16.  
  17. class derivada : public base
  18. {
  19. public:
  20.     derivada() { }
  21.     ~derivada() { }
  22.  
  23.     void saida() { cout << "derivada" << endl; b1::saida(); }
  24. };
  25.  
  26.  
  27. int main() {
  28.  
  29.     base* b = new derivada;
  30.  
  31.     b->saida();
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement