Guest User

Untitled

a guest
Jun 23rd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. class speaker1_int;
  7. class speaker2_int;
  8.  
  9. class speaker1_int{
  10. public:
  11.     virtual void como_estas(speaker2_int* spk2)=0;
  12.     virtual void Hola(speaker2_int* spk2)=0;
  13. };
  14.  
  15. class speaker2_int{
  16. public:
  17.     virtual void mucho_gusto(speaker1_int* spk1)=0;
  18.     virtual void bien_y_vos()=0;
  19.     virtual void start(speaker1_int* spk1)=0;
  20. };
  21.  
  22. class speaker1: public speaker1_int{
  23. private:
  24.     void Hola(speaker2_int* spk2){
  25.         cout << "Hola!" <<endl;
  26.         spk2->mucho_gusto(this);
  27.     }
  28.     void como_estas(speaker2_int* spk2){
  29.         cout << "Como estas?" << endl;
  30.         spk2->bien_y_vos();
  31.     }
  32. };
  33.  
  34. class speaker2: public speaker2_int{
  35. private:
  36.     void mucho_gusto(speaker1_int* spk1){
  37.         cout << "Mucho gusto" <<endl;
  38.         spk1->como_estas(this);
  39.     }
  40.     void bien_y_vos(){
  41.         cout << "Bien y vos?" <<endl;
  42.     }
  43. public:
  44.     void start(speaker1_int* spk1){
  45.         spk1->Hola(this);
  46.     }
  47. };
  48.  
  49. int main (){
  50.     speaker1* spk1;
  51.     speaker2* spk2;
  52.    
  53.     spk1 = new (speaker1);
  54.     spk2 = new (speaker2);
  55.    
  56.     spk2->start(spk1);
  57.     delete spk1;
  58.     delete spk2;
  59.    
  60.     return EXIT_SUCCESS;
  61. }
Add Comment
Please, Sign In to add comment