当我尝试使用此函数时,我在两次返回时遇到错误。如果我将它们注释掉,我就不会收到错误。有什么理由为什么这不起作用?
std::ifstream bipgetConfigurationPath() {
char bipacfFilename[256], bipacfFullPath[512];
char *bipconfigPath;
char *bipdefaultConfigFile;
const char *bipdefaultConfigFileName;
bipdefaultConfigFile = "./Resources/plugins/Xsaitekpanels/D2B_config.txt";
bipdefaultConfigFileName = "D2B_config.txt";
XPLMGetNthAircraftModel(0, bipacfFilename, bipacfFullPath);
bipconfigPath = strstr(bipacfFullPath, bipacfFilename);
strncpy(bipconfigPath, bipdefaultConfigFileName, sizeof(bipacfFilename));
puts(bipacfFullPath);
// Check if ACF-specific configuration exists
std::ifstream bipcustomStream(bipacfFullPath);
if (bipcustomStream.good()) {
return bipcustomStream;
} else {
std::ifstream bipdefaultStream(bipdefaultConfigFile);
if (bipdefaultStream.good()) {
return bipdefaultStream;
}
}
}
谢谢比尔
最佳答案
std::streams 不可复制。
关于c++ - 试图从函数返回 std::ifstream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10180460/