Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class student {
- private:
- string name;
- int course;
- bool gender;
- public:
- student() {}
- student(string _name, string _course, string _gender) : name(_name), course(_course), gender(_gender) {}
- student(const student& a) {
- name = a.name;
- course = a.course;
- gender = a.gender;
- }
- student& operator = (const student& a) {
- name = a.name;
- course = a.course;
- gender = a.gender;
- return *this; // Возвращает ссылку на вызывающий объект
- }
- int input() {
- cout << "Enter name of the student: ";
- cin >> name;
- cout << "Enter course of the student: ";
- cin >> course;
- cout << "Enter gender of the student: ";
- cin >> gender;
- }
- int output() {
- cout << "Name of the student is: " << name << endl;
- cout << "Student's course is: " << course << endl;
- cout << "Gender is: " << gender << endl << endl;
- }
- };
- int main() {
- student student_1 ( "Mariia", 2, "female");
- student student_1 = student_2;
- student student_3;
- student_1 = student_2 = student_3;
- student_3.output();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement