我以为我理解在打开文件时必须将 std::string 转换为 *char ,但我遗漏了一些东西。它编译得很好,但没有打开。尝试了多种变体,但到目前为止,只有硬编码文件中的名称才有效:
// const char * cEMN = cCCA.get_EMNfn().c_str();
// femn.open(cEMN); fails
// femn.open("file-foo.emn"); works
string stdEMN;
stdEMN = cCCA.get_EMNfn();
femn.open(stdEMN.c_str()); // fails
if(!femn)
{
cout << "Open of Original EMN file failed\n";
cout << "EMN file: " << cCCA.get_EMNfn() << endl;
cout << "Press any key to exit" << endl;
ch = getchar();
return 1;
}