我现在正在学习 C++ 模拟课程,并且得到标题中引用的 clang++ 错误。我希望有人能告诉我原因,因为我似乎无法在任何地方找到类似情况的类似错误(尽可能搜索)。
每个Office*
变量定义都会发生错误(第 187 到 190 行)。
175 class EventHandler {
176
177 private:
178 double simulation_time; // current simulation time
179 Office* aid, bursar, registrar, parking;
180 Event* current_event;
181 MinHeap* time_heap;
182
183 public:
184
185 void initialize_simulation() { // initializes simulation time, offices, and event handler (time_heap)
186 simulation_time = 0;
187 aid = new Office(8, Tf); // initializes financial aid office with Tf tellers, with serve time exponentially distributed with mean of 8 minutes
188 bursar = new Office(15, Tb); // initializes bursar office w/ Tb tellers, exp distro, mean 15 min
189 registrar = new Office(5, Tr); // registrar w/ Tr tellers, exp distro, mean 5 min
190 parking = new Office(10,Tp); // parking office w/ Tp tellers, exp distro, mean 10
192 MinHeap* time_heap = new MinHeap();
193 }
如果我替换Office* aid
声明(例如),并更改aid = new Office(15, Tf)
为Office* aid = new Office(15, Tf)
,错误就会消失。我不知道为什么,并且非常想这样做,因为我希望所有这些类指针都是private
.
有趣的是(令人恼火?),MinHeap* time_heap; time_heap = new MinHeap();
不会引起任何问题。我认为这可能与声明一个指针 varprivate
然后在类的一部分中定义它有关public
,但它看起来不像。
帮助?=|