104494
|
1 // test usings header file.
|
|
2
|
|
3 namespace moose {
|
|
4
|
|
5 class Point;
|
|
6
|
|
7 class MyClass;
|
|
8
|
|
9 }
|
|
10
|
|
11
|
|
12 namespace moose {
|
|
13
|
|
14 class Point;
|
|
15
|
|
16 class MyClass {
|
|
17 public:
|
|
18 MyClass() : fVal(0) {
|
|
19 }
|
|
20
|
|
21 ~MyClass() {};
|
|
22
|
|
23 /**
|
|
24 * fVal Accessors
|
|
25 * @{
|
|
26 */
|
|
27 int getVal() const {
|
|
28 return fVal;
|
|
29 }
|
|
30 void setVal(int Val) const {
|
|
31 fVal = Val;
|
|
32 }
|
|
33 /**
|
|
34 * @}
|
|
35 */
|
|
36 private:
|
|
37 int fVal;
|
|
38 };
|
|
39
|
|
40 }
|
|
41
|
|
42 namespace deer {
|
|
43
|
|
44 class Pickle;
|
|
45
|
|
46 };
|
|
47
|
|
48 // Code from Zhiqiu Kong
|
|
49
|
|
50 #ifndef BREAD_H
|
|
51 #define BREAD_H
|
|
52
|
|
53 namespace bread_name {
|
|
54 class bread
|
|
55 {
|
|
56 public:
|
|
57 void geta();
|
|
58 private:
|
|
59 int m_a;
|
|
60 int m_b;
|
|
61 };
|
|
62 }
|
|
63
|
|
64 #endif
|
|
65
|
|
66 // Code from David Engster
|
|
67 // Creating alias types through 'using' trickery
|
|
68
|
|
69 namespace somestuff {
|
|
70 class OneClass {
|
|
71 public:
|
|
72 void aFunc();
|
|
73 int anInt;
|
|
74 };
|
|
75 struct aStruct {
|
|
76 int foo;
|
|
77 int bar;
|
|
78 };
|
|
79 }
|
|
80
|
|
81 namespace otherstuff {
|
|
82 // make otherstuff::OneClass an alias for somestuff::OneClass
|
|
83 using somestuff::OneClass;
|
|
84 }
|
|
85
|
|
86 namespace morestuff {
|
|
87 // make morestuff an alias namespace for somestuff
|
|
88 using namespace somestuff;
|
|
89 // but hide aStruct with own type
|
|
90 struct aStruct {
|
|
91 int anotherFoo;
|
|
92 int anotherBar;
|
|
93 };
|
|
94 }
|
|
95
|
|
96 // We can also create an alias for an alias
|
|
97 namespace evenmorestuff {
|
|
98 using otherstuff::OneClass;
|
|
99 }
|
|
100
|
|
101 // Now with nested namespaces
|
|
102 namespace outer {
|
|
103 namespace inner {
|
|
104 struct StructNested {
|
|
105 int one;
|
|
106 int two;
|
|
107 };
|
|
108 struct AnotherStruct {
|
|
109 int three;
|
|
110 int four;
|
|
111 };
|
|
112 }
|
|
113 }
|
|
114
|
|
115 // Elevate the first struct into 'outer'
|
|
116 // so that we can access it via 'outer::StructNested'
|
|
117 namespace outer {
|
|
118 using outer::inner::StructNested;
|
|
119 }
|
|
120
|
|
121 // Create an alias for a nested namespace
|
|
122 namespace outerinner {
|
|
123 // equivalent to 'namespace outerinner = outer::inner;'
|
|
124 using namespace outer::inner;
|
|
125 }
|
105377
|
126
|
|
127 // arch-tag: f7e59fad-100b-47d3-ae8b-a8390a026ade
|