我正在尝试编写一个函数来检查对象是否存在:
bool UnloadingBay::isEmpty() {
bool isEmpty = true;
if(this->unloadingShip != NULL) {
isEmpty = false;
}
return isEmpty;
}
Run Code Online (Sandbox Code Playgroud)
我是C++的新手,并不确定我的Java背景是否令人困惑,但编译器给出了一个错误:
UnloadingBay.cpp:36: error: no match for ‘operator!=’ in ‘((UnloadingBay*)this)->UnloadingBay::unloadingShip != 0’
Run Code Online (Sandbox Code Playgroud)
我似乎无法弄清楚为什么它不起作用.
这是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();
};
Run Code Online (Sandbox Code Playgroud) 我有一个抽象类,我希望所有子类根据实现定义一个常量 - 它主要是关于类实现的元数据.
在超类中:
protected static final String OBJECT_NAME;
protected static final String OBJECT_DEF;
Run Code Online (Sandbox Code Playgroud)
然后在子类中:
protected static final String OBJECT_NAME = "awesome class";
protected static final String OBJECT_DEF = "an awesome class that is also great";
Run Code Online (Sandbox Code Playgroud)
有没有办法强制类的实现声明一个常量?
我已经跟踪了我正在开发的应用程序的问题,它给了我一个类型转换异常.有趣的是,它说不能投"实体.电影不能投给实体.电影"?!电影是一个ArrayList.
try {
movies = getMovies();
} catch (Exception e) {
e.printStackTrace(System.out);
} finally {
try {
for (Movie movie : movies) {
output.append(" <tr>\n");
output.append(" <td>" + movie.getId() + "</td>");
output.append(" </tr>\n");
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个shell脚本,它会杀死所有正在运行的匹配特定模式的进程,然后重新启动它们.我可以用以下方式显示进程:
ps -ef|grep ws_sched_600.sh|grep -v grep|sort -k 10
Run Code Online (Sandbox Code Playgroud)
其中列出了相关流程:
user 2220258 1 0 16:53:12 - 0:01 /bin/ksh /../../../../../ws_sched_600.sh EDW02_env
user 5562418 1 0 16:54:55 - 0:01 /bin/ksh /../../../../../ws_sched_600.sh EDW03_env
user 2916598 1 0 16:55:00 - 0:01 /bin/ksh /../../../../../ws_sched_600.sh EDW04_env
Run Code Online (Sandbox Code Playgroud)
但我不太确定如何通过进程ID来杀死?