File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ #ifndef PAIR_H
2
+ #define PAIR_H
3
+
4
+ template <T1,T2> class Pair {
5
+
6
+ public :
7
+
8
+ Pair ():
9
+ m_first (),
10
+ m_second ()
11
+ { }
12
+
13
+ Pair (T1 firstParam, T2 secondParam):
14
+ m_first (firstParam),
15
+ m_second (secondParam)
16
+ { }
17
+
18
+ Pair (Pair otherPair):
19
+ m_first (otherPair.first()),
20
+ m_second (otherPair.second())
21
+ { }
22
+
23
+ Pair& operator =
24
+ (const Pair &right){
25
+ return Pair (right.first (), right.second ());
26
+ }
27
+
28
+ ostream& operator << (ostream &os){
29
+ os << first ();
30
+ os << second ();
31
+ }
32
+
33
+ T1& first (void ){
34
+ return &m_first;
35
+ }
36
+
37
+ const T1& first (void ) const {
38
+ return &m_first;
39
+ }
40
+
41
+ T2& second (void ){
42
+ return &m_second;
43
+ }
44
+
45
+ const T2& second (void ) const {
46
+ return &m_second;
47
+ }
48
+
49
+ private:
50
+
51
+ T1 m_first ;
52
+ T2 m_second;
53
+
54
+ }
55
+ #endif // PAIR_H
You can’t perform that action at this time.
0 commit comments