Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1.  
  2. template<unsigned Extent>
  3. struct Feeling {
  4.     virtual void ExpressFeelingToVioletta() const = 0;
  5. };
  6.  
  7. struct Love : public Feeling<100>  {
  8.     void ExpressFeelingToVioletta() const override final {
  9.         std::cout << "Violetta, I love you" << std::endl;
  10.     }
  11. };
  12.  
  13. struct Care : public Feeling<100> {
  14.     void ExpressFeelingToVioletta() const override final {
  15.         std::cout << "Violetta, I wanna care of you" << std::endl;
  16.     }
  17. };
  18.  
  19. struct Support : public Feeling<100> {
  20.     void ExpressFeelingToVioletta() const override final {
  21.         std::cout << "Violetta, I wanna always support you" << std::endl;
  22.     }
  23. };
  24.  
  25. struct Admiration : public Feeling<100> {
  26.     void ExpressFeelingToVioletta() const override final {
  27.         std::cout << "Violetta, i think you are the best girl for me" << std::endl;
  28.     }
  29. };
  30.  
  31.  
  32. struct Danil {
  33.     template<typename... Feelings>
  34.     static void LoveVioletta(Feelings&&... feelings) {
  35.         (feelings.ExpressFeelingToVioletta(), ...);
  36.     }
  37. };
  38.  
  39. struct Violetta {
  40.     static void NotLoveDanil() {
  41.         std::cout << "Danil, sorry, i don't like you" << std::endl;
  42.     }
  43. };
  44.  
  45.  
  46. int main () {
  47.  
  48.     Danil::LoveVioletta(Love{}, Care{}, Support{}, Admiration{});
  49.     Violetta::NotLoveDanil();
  50.  
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement