-
Notifications
You must be signed in to change notification settings - Fork 2
/
T31.cpp
73 lines (61 loc) · 1.54 KB
/
T31.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
63
64
65
66
67
68
69
70
71
72
73
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
//----------------------------------------------------
//自定义命名空间
namespace derry {
int age = 33;
char *name = "derry";
void show() {
cout << "name:" << name << ", age:" << age << endl;
};
}
//声明在类外层,所有方法使用
using namespace derry;
//----------------------------------------------------
namespace derry2 {
int age = 33;
char *name = "derry";
void show() {
cout << "name:" << name << ", age:" << age << endl;
};
}
using namespace derry2;
//----------------------------------------------------
//命名空间嵌套
namespace derry3 {
void show3() {
cout << "show3" << endl;
}
namespace derry4 {
void show4() {
cout << "show4" << endl;
}
}
}
using namespace derry3;
//----------------------------------------------------
/**
* NDK重要函数
* @return
*/
int main31() {
std::cout << "九阳神功" << std::endl;
//局部声明使用
//----------------------------------------------------
// using namespace derry;
int ageValue = derry::age;
char *nameValue = derry::name;
derry::show();
//----------------------------------------------------
int ageValue2 = derry2::age;
char *nameValue2 = derry2::name;
derry2::show();
derry3::show3();
derry4::show4();
// 命名空间多层嵌套声明
// using namespace derry3::derry4;
//----------------------------------------------------
return 0;
}