-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
62 lines (47 loc) · 856 Bytes
/
test.cpp
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
60
61
62
#include "iostream"
using namespace std;
int ca_var =1;
template <typename T>
void swap(T &a, T &b)
{
T tmp = a;
a = b;
b = tmp;
a++;
b++;
}
void TestSwap()
{
int iA = 10;
int iB = 20;
double dC = 1.1;
double dD = 2.1;
char *str1 = "ABC";
char *str2 = "abc";
::swap(iA, iB);
cout << iA << "," << iB << endl;
std::swap(iA, iB);
cout << iA << "," << iB << endl;
swap(iA, iB);
cout << iA << "," << iB << endl;
std::swap(dC, dD);
cout << dC << "," << dD << endl;
::swap(str1, str2);
cout << str1 << ", " << str2 << endl;
}
class CA {
public:
int ca_var;
CA():ca_var(0) {}
void f() {
cout << "::ca_var = " << ::ca_var << endl;
cout << "ca_var = " << ca_var << endl; }
};
//int ca_var=2;
int main()
{
TestSwap();
CA mca;
mca.f();
return 0;
}