有关CObject的异常处理问题。
MFC中,无法throw在栈中的CObject的子类对象,比如下面的代码。
CFileException e;
throw e;
会报错:
e:\UserData\Project\Civ3\VC7\PatchGenerator\PatchGeneratorDlg.cpp(387) : error C2700: 'CFileException' : cannot be thrown (use /W4 for more info)
e:\UserData\Project\Civ3\VC7\PatchGenerator\PatchGeneratorDlg.cpp(387) : warning C4670: 'CFileException' : this base class is inaccessible
如果换成:
throw new CFileException;
或者
CFileException e;
throw &e;
就没有关系。
不过这样的异常处理好象不是很好。请问为什么CObject的子类会有这样的问题?