MasterGun

Untitled

May 2nd, 2020
36
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. class Person{
  5. string name;
  6. public:
  7. Person(string name) {
  8. this->name;
  9. }
  10. virtual string getproces() { return "Exists"; }
  11. };
  12. class Student : public Person {
  13. public:
  14. Student(string name) : Person(name) { }
  15. virtual string getproces() { return "Tries to do something usefull"; }
  16. };
  17. class Employee : public Student {
  18. public:
  19. Employee(string name) : Student(name) { }
  20. virtual string getproces() { return "work,work,work and again work"; }
  21. };
  22. void callProcess(Person& P) {
  23. cout << P.getproces() << endl;
  24. }
  25. int main(){
  26. setlocale(LC_ALL, "Russian");
  27. Person p("Yarik");
  28. Student s("Tolik");
  29. Employee e("Sanya");
  30. callProcess(p);
  31. callProcess(s);
  32. callProcess(e);
  33.  
  34. return 0;
  35. }
RAW Paste Data