fork download
  1. #include <iostream>
  2.  
  3. class Human {
  4. private:
  5. int age;
  6. std::string name;
  7. public:
  8. Human(): age(0) {
  9. std::cout << "Human being born\n";
  10. }
  11. ~Human() {
  12. std::cout << "Human being died\n";
  13. }
  14.  
  15. void giveName(const std::string& input) {
  16. name = input;
  17. }
  18.  
  19. void birthday() {
  20. ++age;
  21. }
  22.  
  23. virtual void greeting() {
  24. std::cout << "Hello, my name is " << name << '\n';
  25. }
  26. };
  27.  
  28. class Employee : public Human {
  29. private:
  30. int paycheck;
  31. public:
  32. Employee(): paycheck(12000) {
  33. std::cout << "Employee hired"
  34. }
  35. //etc
  36. };
  37.  
  38.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty