MasterGun

Untitled

Nov 1st, 2020 (edited)
75
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2. #include "CPersom.h"
  3. #include <string>
  4. #include <iostream>
  5. class CEmployee : public CPersom
  6. {
  7. public:
  8. string duty;
  9. string company_name;
  10. int years;
  11. void showdata() override {
  12. cout << duty << "," << company_name << "," << years << endl;
  13. }
  14. };
  15. #pragma once
  16. #include <string>
  17. #include <iostream>
  18. #include "CPersom.h"
  19. using namespace std;
  20. class CStudent : public CPersom
  21. {
  22. public:
  23. double bal;
  24. void showdata()override
  25. {
  26. cout << bal << endl;
  27. }
  28. };
  29. #pragma once
  30. #include <string>
  31. #include <iostream>
  32. using namespace std;
  33. class CPersom
  34. {
  35. public:
  36. string name;
  37. string surname;
  38. string thirdname;
  39. void virtual showdata(){
  40. cout << name << "," << surname << "," << thirdname;
  41. };
  42. };
  43. #include <iostream>
  44. #include <string>
  45. #include "CEmployee.h"
  46. #include "CStudent.h"
  47. #include "CPersom.h"
  48. using namespace std;
  49.  
  50. int main()
  51. {
  52. setlocale(LC_ALL, "rus");
  53. CStudent stud;
  54. CStudent* cs = &stud;
  55. CPersom* cp = &stud;
  56. CEmployee emp;
  57. CEmployee* CE = &emp;
  58. cp->name ="name";
  59. cp->surname = "sname";
  60. cp->thirdname = "lastname";
  61. cs->bal = 10;
  62. stud.showdata();
  63. CE->company_name = "cnn";
  64. CE->duty = "WORK";
  65. CE->years = 10;
  66. emp.showdata();
  67.  
  68. return 0;
  69. }
RAW Paste Data