Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <stdio.h>
- #include <iostream>
- class student
- {
- public:
- int course;
- int age;
- student()
- {
- course = 1;
- age = 18;
- }
- student(int course, int age)
- {
- course = course;
- age = age;
- }
- student(const student &obj)
- {
- course = obj.course;
- age = obj.age;
- }
- ~student()
- {
- std::cout<<"\nДеcтруктор сработал!\n";
- }
- int getAge(){
- return age;
- }
- void setAge(int age){
- age = age;
- }
- int getCourse(){
- return course;
- }
- void setCourse(int course){
- course = course;
- }
- };
- int main() {
- student s1;
- student s2(2,20);
- student s3(s2);
- s1.setAge(21);
- s1.setCourse(5);
- cout << s1.getAge() << " " << s1.getCourse();
- cout << s2.getAge() << " " << s2.getCourse();
- cout << s3.getAge() << " " << s3.getCourse();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement