Advertisement
Josif_tepe

Untitled

Oct 28th, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 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.     }
  15.     Student(string _name, string _surname, int _age) {
  16.         name = _name;
  17.         surname = _surname;
  18.         age = _age;
  19.     }
  20.    
  21.     Student(const Student &object) {
  22.         name = object.name;
  23.         surname = object.surname;
  24.         age = object.age;
  25.     }
  26.    
  27.     string get_name() {
  28.         return name;
  29.     }
  30.     string get_surname() {
  31.         return surname;
  32.     }
  33.     int get_age() {
  34.         return age;
  35.     }
  36.    
  37.     void set_name(string s) {
  38.         name = s;
  39.     }
  40.     void set_surname(string s) {
  41.         surname = s;
  42.     }
  43.     void set_age(int a) {
  44.         age = a;
  45.     }
  46. };
  47. int main() {
  48.  
  49.     Student s;
  50.     s.set_name("josif");
  51.     s.set_surname("tepegjozov");
  52.     s.set_age(100);
  53.    
  54.     cout << s.get_name() << " " << s.get_surname() << " " << s.get_age() << endl;
  55.     return 0;
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement