Facebook
From Buff Earthworm, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 219
  1. #include <iostream>
  2. #include <windows.h>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. class MalyObiekt
  8. {
  9. public:
  10.     MalyObiekt() {cout<<"mo_kd"<<endl;}
  11. };
  12.  
  13. class Obiekt
  14. {
  15.  
  16. public:
  17.     Obiekt() {cout<<"kd"<<endl;}
  18.     Obiekt(const Obiekt &kk) {cout<<"kk"<<endl;}
  19.  
  20.     Obiekt operator -(Obiekt &o)
  21.     {
  22.         Obiekt so;
  23.         cout<<"o-"<<endl;
  24.         return so;
  25.     }
  26.  
  27.      Obiekt operator =(Obiekt &o)
  28.      {
  29.          cout<<"op"<<endl;
  30.          return *this;
  31.      }
  32.  
  33.      void funkcja(MalyObiekt &mo)
  34.      {    cout<<"des"<<endl;    }
  35.  
  36.      ~Obiekt()
  37.      {
  38.      cout<<"des"<<endl;
  39.      }
  40. };
  41.  
  42.  
  43. main()
  44. {
  45.     Obiekt o1, o2, *o3;
  46.     MalyObiekt mo;
  47.     o3 = new Obiekt();
  48.     *o3 = o1 - o2;    //nie dziala, o co chodzi?
  49.     o3->funkcja(mo); //funkcja nic nie zwroci bo przyjmuje argumenty typu MalyObiekt
  50.  
  51.  
  52.     return 0;
  53. }
  54.