首先,这里有一些代码:
class A
{
public:
    A()
    {
        //...
        readTheFile(mySpecialPath);
        //...
    }
    A(boost::filesystem::path path)
    {
        //...
        readTheFile(path);
        //...
    }
protected:  
    void readTheFile(boost::filesystem::path path)
    {
        //First, check whether path exists e.g. by
        //using boost::filesystem::exists(path).
        //But how to propagate an error to the main function?
    }
    //...
};
int main(int argc, char **argv)
{
    A myClass;
    //Some more code which should not be run when A::readTheFile fails
}
让主函数知道 A::readTheFile 无法打开文件的好解决方案是什么?我想在打开文件失败时终止执行。
提前谢谢了!