我想写一个对象是否存在,将检查功能:我怎么能检查对象是否存在于C++
bool UnloadingBay::isEmpty() {
bool isEmpty = true;
if(this->unloadingShip != NULL) {
isEmpty = false;
}
return isEmpty;
}
我是相当新的C++和不知道如果我的Java背景是混乱东西,但编译器给出了一个错误:
UnloadingBay.cpp:36: error: no match for ‘operator!=’ in ‘((UnloadingBay*)this)->UnloadingBay::unloadingShip != 0’
我似乎无法弄清楚为什么它不起作用。
下面是类UnloadingBay声明:
class UnloadingBay {
private:
Ship unloadingShip;
public:
UnloadingBay();
~UnloadingBay();
void unloadContainer(Container container);
void loadContainer(Container container);
void dockShip(Ship ship);
void undockShip(Ship ship);
bool isEmpty();
};
正在卸载船舶类功能?你能发布你的类声明吗? – 2010-09-04 03:14:52
no unloadingShip是unLoadingBay的一个属性,它是isEmpty是其成员的类 – 2010-09-04 03:20:16
pharma_joe:作为一般提示:您在Java中学到的所有内容?算了吧。它不会帮助你在C++中。 – greyfade 2010-09-04 04:45:48