]> code.delx.au - gnu-emacs/blob - test/cedet/tests/testsubclass.hh
; Auto-commit of loaddefs files.
[gnu-emacs] / test / cedet / tests / testsubclass.hh
1 // testsubclass.hh --- unit test for analyzer and complex C++ inheritance
2
3 // Copyright (C) 2007-2016 Free Software Foundation, Inc.
4
5 // Author: Eric M. Ludlam <eric@siege-engine.com>
6
7 // This file is part of GNU Emacs.
8
9 // GNU Emacs is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13
14 // GNU Emacs is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18
19 // You should have received a copy of the GNU General Public License
20 // along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 //#include <cmath>
23 // #include <stdio.h>
24
25 #ifndef TESTSUBCLASS_HH
26 #define TESTSUBCLASS_HH
27
28 namespace animal {
29
30 class moose {
31 public:
32 moose() : fFeet(0),
33 fIsValid(false)
34 { }
35
36 virtual void setFeet(int);
37 int getFeet();
38
39 void doNothing();
40
41 enum moose_enum {
42 NAME1, NAME2, NAME3 };
43
44
45 protected:
46
47 bool fIsValid;
48 int fIsProtectedInt;
49
50 private:
51 int fFeet; // Usually 2 or 4.
52 bool fIsPrivateBool;
53
54 }; // moose
55
56 int two_prototypes();
57 int two_prototypes();
58
59 class quadruped {
60 public:
61 quadruped(int a) : fQuadPrivate(a)
62 { }
63
64 int fQuadPublic;
65
66 protected:
67 int fQuadProtected;
68
69 private:
70 int fQuadPrivate;
71
72 };
73
74 }
75
76
77 namespace deer {
78
79 class moose : public animal::moose {
80 public:
81 moose() : fAntlers(false)
82 { }
83
84 void setAntlers(bool);
85 bool getAntlers();
86
87 void doSomething();
88
89 protected:
90
91 bool fSomeField;
92
93 private:
94 bool fAntlers;
95
96 };
97
98 } // deer
99
100 // A second namespace of the same name will test the
101 // namespace merging needed to resolve deer::alces
102 namespace deer {
103
104 class alces : public animal::moose {
105 public:
106 alces(int lat) : fLatin(lat)
107 { }
108
109 void setLatin(bool);
110 bool getLatin();
111
112 void doLatinStuff(moose moosein); // for completion testing
113
114 moose createMoose(); // for completion testing.
115
116 protected:
117 bool fAlcesBool;
118 int fAlcesInt;
119
120 private:
121 bool fLatin;
122 int fGreek;
123 };
124
125 };
126
127 // A third namespace with classes that does protected and private inheritance.
128 namespace sneaky {
129
130 class antelope : public animal::quadruped {
131
132 public:
133 antelope(int a) : animal::quadruped(),
134 fAntyProtected(a)
135 {}
136
137 int fAntyPublic;
138
139 bool testAccess();
140
141 protected:
142 int fAntyProtected;
143
144 private :
145 int fAntyPrivate;
146
147 };
148
149 class jackalope : protected animal::quadruped {
150
151 public:
152 jackalope(int a) : animal::quadruped(),
153 fBunny(a)
154 {}
155
156 int fBunnyPublic;
157
158 bool testAccess();
159
160 protected:
161 bool fBunnyProtected;
162
163 private :
164 bool fBunnyPrivate;
165
166 };
167
168 // Nothing specified means private.
169 class bugalope : /* private*/ animal::quadruped {
170
171 public:
172 bugalope(int a) : animal::quadruped(),
173 fBug(a)
174 {}
175
176 int fBugPublic;
177
178 bool testAccess();
179 protected:
180 bool fBugProtected;
181
182 private :
183 bool fBugPrivate;
184
185 };
186
187
188 };
189
190 #endif
191