1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <iostream>
using namespace std;
template <typename T1, typename T2>
class Pair {
public:
Pair(T1, T2);
void setFirst(T1);
void setSecond(T2);
T1 getFirst() const;
T2 getSecond() const;
void print() const;
private:
T1 object1;
T2 object2;
};
template <typename T1, typename T2>
Pair<T1,T2>::Pair(T1 first,T2 second){
object1 = first;
object2 = second;
}
template <typename T1, typename T2>
void Pair<T1,T2>::setFirst(T1 first){
Pair<T1,T2>::object1=first;
}
template <typename T1, typename T2>
void Pair<T1,T2>::setSecond(T2 second){
Pair<T1,T2>::object2=second;
}
template <typename T1, typename T2>
T1 Pair<T1,T2>::getFirst() const{
return object1;
}
template <typename T1, typename T2>
T2 Pair<T1,T2>::getSecond() const{
return object2;
}
template <typename T1, typename T2>
void Pair<T1,T2>::print() const{
cout << "Object 1 : " << object1 << endl;
cout << "Object 2 : " << object2 << endl;
}
int main () {
//help me in here
cin.get();
}
|