Guest User

Untitled

a guest
Dec 16th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. template <class T1, class T2>
  4. class Pair {
  5. private:
  6. T1 a;
  7. T2 b;
  8. public:
  9. T1 & first();
  10. T2 & second();
  11. T1 first() const { return a; }
  12. T2 second() const { return b; }
  13. Pair(const T1 & aval, const T2 & bval) : a(aval), b(bval) { }
  14. Pair() {}
  15. };
  16. template<class T1, class T2>
  17. T1 & Pair<T1,T2>::first() { return a; }
  18.  
  19. template<class T1, class T2>
  20. T2 & Pair<T1,T2>::second() { return b; }
  21.  
  22. Pair myPair(5,10);
  23. cout << myPair.first();
Add Comment
Please, Sign In to add comment