Jommiey

Lektion3_7.2

Nov 19th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. class Race
  2. {
  3. public:
  4.   virtual void eat() = 0;
  5.   //...
  6. };
  7.  
  8. class Sun_Insensitive
  9. {
  10.   //...
  11. };
  12.  
  13. class Strong
  14. {
  15.   //...
  16. };
  17.  
  18. class Repulsive
  19. {
  20.   //...
  21. };
  22.  
  23. class Intelligent
  24. {
  25.   //...
  26. };
  27.  
  28. class Human : public Sun_Insenstive, public Strong, public, intelligent, public Race
  29. {
  30. public:
  31.   void eat() override;
  32.   //...
  33. };
  34.  
  35. class Orc : public Repulsive, public Strong, public Race
  36. {
  37. public:
  38.   void eat() override;
  39.   //...
  40. };
  41.  
  42. class Uruk_Hai : public Sun_Insensitive, public Repulsive, public strong, public Race
  43. {
  44. public:
  45.   //...
  46. };
  47.  
  48. Uruk_Hai* uruk = new Uruk_Hai;
  49. uruk->eat();
  50.  
  51. int eat_dinner(Race* dinner_guest)
  52. {
  53.   Race* r = dynamic_cast<Repulsive>(dinner_guest);
  54.   if(r == nullptr)
  55.   {
  56.     return 1;
  57.   }
  58.   return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment