我尝试在类中的函数中打开一个文件:
void openFile(){
inputFile.open(inputFilename.c_str());
if (inputFile.is_open()){
inputFile.read(buffer, skipAtBegin);
} else {
cerr << "Cannot open file: " << inputFilename << endl;
exitNow();
}
}
在main()中我只返回1,但是我怎样才能在子子函数类中做到最好/最简单的方法?
将所有步骤返回1到主?
使用ecxeptions?
任何exit()
命令?
答案 0 :(得分:1)
通常有三个选项:
希望有人能提出其他选择。