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, int _course, bool _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; // ?????????? ?????? ?? ?????????? ??????
- }
- void input() {
- string s_gender;
- cout << "Enter name of the student: ";
- cin >> name;
- cout << "Enter course of the student: ";
- cin >> course;
- cout << "Enter gender of the student (male or female): ";
- cin >> s_gender;
- if (s_gender == "male") {
- gender = false;
- } else if (s_gender == "female") {
- gender = true;
- } else {
- cout << "error";
- exit(1);
- }
- }
- void output() {
- cout << "Name of the student is: " << name << endl;
- cout << "Student's course is: " << course << endl;
- cout << "Gender is: ";
- if (gender) {
- cout << "female";
- } else {
- cout << "male";
- }
- cout << endl << endl;
- }
- };
- int main() {
- student student_1("Mariia", 2, "female");
- student_1.output();
- student student_2 = student_1;
- student_2.output();
- student student_3;
- student_3 = student_2 = student_1;
- student_3.output();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement