Advertisement
Josif_tepe

Untitled

Dec 12th, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Student {
  6. private:
  7.     char * niza;
  8.  
  9. public:
  10.     Student() {
  11.        
  12.     }
  13.     Student(char * _niza) {
  14.         niza = new char[strlen(_niza)];
  15.         strcpy(niza, _niza);
  16.     }
  17.     Student(const Student & tmp) {
  18.         niza = new char[strlen(tmp.niza)];
  19.         strcpy(niza, tmp.niza);
  20.     }
  21.     ~Student() {
  22.         delete[] niza;
  23.     }
  24.    
  25.     void set_niza(char * _niza) {
  26.         niza = new char[strlen(_niza)];
  27.         strcpy(niza, _niza);
  28.     }
  29.    
  30.     char * get_niza() {
  31.         return niza;
  32.     }
  33.    
  34.    
  35. };
  36.  
  37. int main()
  38. {
  39.     Student s("abcdef");
  40.    
  41.     cout << s.get_niza() << endl;
  42.  
  43.     return 0;
  44.  
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement