//tegemist on muudetud näitega, mis jutustab oma tööst-tegemistest natuke //rohkem #include #include #include class TSample { private: char *s; public: TSample(); // Normal Constructor TSample(const TSample &ob); // Copy Constructor ~TSample() { cout << "Freeing s... "; if(s) delete[] s; cout << "done" << endl; } void Show(void){ cout << s << endl; } void Set(char *_s); TSample operator=(TSample ob); }; TSample::TSample() { cout<<"Konstruktor alustatud"< strlen(s)){ delete[] s; s = new char[strlen(ob.s)+1]; if(!s){ cout << "Allocation Error" << endl; exit(1); } } strcpy(s, ob.s); cout<<"Operaatori ümberlaadimine lõpetatud"<> input; str.Set(input); cout<<"Funktsioon Input lõpetatud"< Funktsioon Input alustatud Konstruktor alustatud Konstruktor lõpetatud Input string: string Funktsioon Set alustatud Funktsioon Set lõpetatud Funktsioon Input lõpetatud Copy Konstruktor alustatud Copy Konstruktor lõpetatud Freeing s... done Operaatori ümberlaadimine alustatud Operaatori ümberlaadimine lõpetatud Copy Konstruktor alustatud Copy Konstruktor lõpetatud Freeing s... done Freeing s... done string Freeing s... done */