我現在正在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();
不會造成任何問題。我認爲這可能與聲明一個指針var爲private
,然後在類的public
部分中定義它,但它看起來不是。
有幫助嗎? = |
我不確定他們是否真的需要*指針,但是如果他們這樣做,這就是做到這一點的方法! – juanchopanza
@ juanchopanza你可能是對的。 –