Class pair_int_char{
public:
int first;
char second;
pair_int_char(int x,char y) : first(x), second(y) {}
};
pair_int_char pair(13,'a');
cout << pair1.first << endl;
cout << pair1.second << endl;
Class pair_bool_double{
public:
int first;
char second;
pair_bool_double(bool x,double y) : first(x), second(y) {}
};
pair_bool_double pair(true,0.1);
cout << pair2.first << endl;
cout << pair2.second << endl;
->
using STL Class Template
template <typename T1, typename T2>
class pair {
public:
T1 first;
T2 second;
pair(T1 x, T2 y) : first(x), second(y) {}
};
pair<int,char> pair3(13,'a);
pair<bool,double> pair4(true,0.1); ...
using STL Class Template reference parameters
template <typename T1, typename T2>
class pair {
public:
T1 first;
T2 second;
pair() : first(T1()),second(T2()) {}
pair(const T1* x,const T2& y) : first(x), second(y) {}
};
위에 같은 결과값의 두개 코드를 비교...