fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Object {
  5. public:
  6. virtual void move() = 0;
  7. virtual void move(string) = 0;
  8. virtual void powerOn() = 0;
  9. virtual void powerOff() = 0;
  10. virtual void speak() = 0;
  11. };
  12.  
  13. class Electronics : public Object {
  14. public:
  15. virtual void move() override {}
  16. virtual void move(string) override {}
  17. virtual void powerOn() override {cout << "powerOn" << endl;}
  18. virtual void powerOff() override {cout << "powerOff" << endl;}
  19. virtual void speak() override {}
  20. };
  21.  
  22. class Phone : public Electronics {
  23. virtual void powerOn() override {cout << "phone:powerOn" << endl;}
  24. virtual void powerOff() override {cout << "phone:powerOff" << endl;}
  25. };
  26.  
  27. int main() {
  28. Object* phone = new Phone;
  29.  
  30. phone->move();
  31. phone->powerOn();
  32. phone->powerOff();
  33. phone->speak();
  34.  
  35. delete phone;
  36. return 0;
  37. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
phone:powerOn
phone:powerOff