Advertisement
obernardovieira

Two base classes can communicate

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