fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class DoSomething
  6. {
  7. public:
  8. virtual void unko() = 0;
  9. };
  10.  
  11. class Humanoid
  12. {
  13. public:
  14. virtual void say() = 0;
  15. };
  16.  
  17. class Human : public Humanoid, public DoSomething
  18. {
  19. public:
  20. void unko(){
  21. _unko();
  22. }
  23. void say(){ unko(); }
  24. private:
  25. virtual void _unko(){
  26. cout << "Ya-Hoo!!!!!!!!!!!!" << endl;
  27. }
  28. };
  29.  
  30. class Woman : public Human
  31. {
  32. public:
  33. private:
  34. virtual void _unko(){
  35. cout << "Iyaaaaaaaa!!!!!!!!" << endl;
  36. }
  37. };
  38.  
  39. class BeautifulGirl : public Humanoid
  40. {
  41. public:
  42. void say(){ cout << "I love you." << endl;}
  43.  
  44. };
  45.  
  46. int main()
  47. {
  48. Human a;
  49. Woman b;
  50. BeautifulGirl c;
  51. Humanoid *tmps[] = { &a, &b, &c };
  52. for(int i=0; i<3; i++){ tmps[i]->say(); }
  53. //c.unko(); // !error
  54. return 0;
  55. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Ya-Hoo!!!!!!!!!!!!
Iyaaaaaaaa!!!!!!!!
I love you.