Advertisement
Guest User

Untitled

a guest
May 27th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3.  
  4. class student
  5. {
  6.    public:
  7.    int course;  
  8.    int age;
  9.  
  10.    student()            
  11.    {
  12.       course = 1;
  13.       age = 18;
  14.    }
  15.  
  16.    student(int course, int age)
  17.    {
  18.       course = course;
  19.       age = age;
  20.    }
  21.  
  22.    student(const student &obj)            
  23.    {
  24.       course = obj.course;
  25.       age = obj.age;
  26.    }
  27.  
  28.    ~student()
  29.    {
  30.       std::cout<<"\nДеcтруктор сработал!\n";
  31.    }
  32.    
  33.    int getAge(){
  34.        return age;
  35.    }
  36.    
  37.    void setAge(int age){
  38.        age = age;
  39.    }
  40. };
  41.  
  42. int main() {
  43.     student s1;
  44.     student s2;
  45.     s1(2, 20);
  46.     s2(s1);
  47.     s2.getAge;
  48.     s1.setAge(15);
  49.     std::cout<<s1.getAge;
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement