Advertisement
Guest User

Untitled

a guest
May 11th, 2018
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using std::cout;
  4. using std::endl;
  5.  
  6.  
  7. template <class T>
  8. class Pair
  9. {
  10. public:
  11.   Pair(T left, T right): left(left), right(right) {}
  12.   const T& getLeft() const { return left; }
  13.   const T& getRight() const { return right; }
  14.  
  15. private:
  16.   T left;
  17.   T right;
  18. };
  19.  
  20.  
  21. template <template <class ST> class T>
  22. class Node
  23. {
  24. public:
  25.   Node(T<ST> value):
  26.     value(value)
  27.   {
  28.   }
  29.   const auto& getValue() const { return value; }
  30.   auto getLeft() { return value.getLeft(); } // ST getLeft()
  31.   auto getRight() { return value.getRight(); } // ST getRight()
  32.  
  33. private:
  34.   T<ST> value;
  35. };
  36.  
  37.  
  38. int main()
  39. {
  40.   Node<Pair<int>> node({5, 6});
  41.  
  42.   // cout << "Created a node with a pair with left "
  43.   //      << node.getLeft()
  44.   //      << " and right "
  45.   //      << node.getRight()
  46.   //      << endl;
  47.  
  48.   return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement