Advertisement
35657

Untitled

May 14th, 2024
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1.  
  2. #include <string>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9.  
  10. // Рабочий
  11. class Worker {
  12. public:
  13.  
  14.     void SetSpeciality(string speciality) {
  15.         speciality_ = speciality;
  16.     }
  17.     string GetSpeciality() const {
  18.         return speciality_;
  19.     }
  20.  
  21. private:
  22.     string speciality_;
  23. };
  24.  
  25.  
  26. // Студент
  27. class Student {
  28. public:
  29.  
  30.     void SetFaculty(string faculty) {
  31.         faculty_ = faculty;
  32.     }
  33.     string GetFaculty() const {
  34.         return faculty_;
  35.     }
  36.  
  37. private:
  38.     string faculty_;
  39. };
  40.  
  41.  
  42. //
  43. class ExternalStudent : public Worker, public Student  {
  44.  
  45. };
  46.  
  47.  
  48. int main() {
  49.     setlocale(LC_ALL, "ru");
  50.  
  51.     ExternalStudent ex;
  52.  
  53.     ex.SetSpeciality("Builder");
  54.     ex.SetFaculty("Programming");
  55.  
  56.     cout << ex.GetSpeciality() << " " << ex.GetFaculty() << endl;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement