Advertisement
Josif_tepe

Untitled

Oct 28th, 2021
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Student {
  5. private:
  6.     string name, surname;
  7.     int age;
  8.    
  9. public:
  10.     Student() {
  11.         name = "";
  12.         surname = "";
  13.         age = 0;
  14.         cout << "empty" << endl;
  15.     }
  16.     Student(string _name, string _surname, int _age) {
  17.         name = _name;
  18.         surname = _surname;
  19.         age = _age;
  20.         cout << "parameterized" << endl;
  21.     }
  22.    
  23.     Student(const Student &object) {
  24.         name = object.name;
  25.         surname = object.surname;
  26.         age = object.age;
  27.         cout << "copy" << endl;
  28.     }
  29.    
  30. };
  31. int main() {
  32.  
  33.     Student s;
  34.     Student s1("josif", "tepegjozov", 100);
  35.     Student s2 = s1;
  36.    
  37.     return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement