Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- template <class T1, class T2>
- class Pair {
- private:
- T1 a;
- T2 b;
- public:
- T1 & first();
- T2 & second();
- T1 first() const { return a; }
- T2 second() const { return b; }
- Pair(const T1 & aval, const T2 & bval) : a(aval), b(bval) { }
- Pair() {}
- };
- template<class T1, class T2>
- T1 & Pair<T1,T2>::first() { return a; }
- template<class T1, class T2>
- T2 & Pair<T1,T2>::second() { return b; }
- Pair myPair(5,10);
- cout << myPair.first();
Add Comment
Please, Sign In to add comment