-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwapify.cc
More file actions
59 lines (43 loc) · 1022 Bytes
/
Swapify.cc
File metadata and controls
59 lines (43 loc) · 1022 Bytes
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
55
56
57
58
59
#ifndef _SWAPIFY_CC_
#define _SWAPIFY_CC_
#include <iostream>
#include "Swapify.h"
#include "Swap.h"
using namespace std;
template <class Type>
Swapify <Type> :: Swapify () {
}
template <class Type>
Swapify <Type> :: Swapify (const Type castFromMe) {
data = castFromMe;
}
template <class Type>
Swapify <Type> :: ~Swapify () {
}
template <class Type>
Swapify <Type> :: operator Type () {
return data;
}
template <class Type> Type&
Swapify <Type> :: getData(){
return data;
}
template <class Type> void
Swapify <Type> :: Swap (Swapify &withMe) {
SWAP(data, withMe.data);
}
template <class Type> void
Swapify <Type> :: CopyFrom (Swapify &fromMe) {
data = fromMe.data;
}
// redefine operator << for printing
template <class Type> ostream&
operator<<(ostream& output, const Swapify<Type>& _s) {
Swapify<Type> newObject;
newObject.Swap(const_cast<Swapify<Type>&>(_s));
Type st = newObject;
output << st;
newObject.Swap(const_cast<Swapify<Type>&>(_s));
return output;
}
#endif //_SWAPIFY_CC_