C++名字命名空间实现判等
效果:相等为1,不等为0
/*
功能:名字命名空间
日期:2013-09-12
*/
#include<iostream>
#include <string>
using std::endl;
using std::cout;
namespace equalSting
{
bool isEqual(char *p,char *q)
{
if (strcmp(p,q))
{
return 0;
}
else
{
return 1;
}
}
}
namespace equalInt
{
bool isEqual(int x,int y)
{
if ( x == y )
{
return 1;
}
else
{
return 0;
}
}
}
int main(void)
{
char *p = "abc";
char *q = "abc";
bool boo = equalSting::isEqual(p,q);
cout << boo << endl;
p = "abd";
q = "abc";
boo = equalSting::isEqual(p,q);
cout << boo << endl;
int x = 2 , y = 2;
boo = equalInt::isEqual(x,y);
cout<<boo<<endl;
system("pause");
return 0;
}
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
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
预览
除特别注明外,本站所有文章均为 Windcoder网 原创,转载请注明出处来自: c-namespace-names-etc-to-achieve-sentence
Loading comments...

预览
暂无数据