1.在写类的成员函数的时候,忘记在成员函数前写类名字,导致类中的数据成员不可见,报错
QVector3d CalFaceNormal(const int f0, const int f1, const int f2, QVector3d &faceNormal)
{
QNormal n0, n1, n2;
n0 = normals.at(f0);
n1 = normals.at(f1);
n2 = normals.at(f2);
faceNormal = (n0+n1+n2)/3.0;
return faceNormal;
}
上面这么写会导致normals不可见,报错为:
error C2065: 'normals' : undeclared identifier
因此,正确的写法应该为:
QVector3d QScene::CalFaceNormal(const int f0, const int f1, const int f2, QVector3d &faceNormal)
2.在用三角形的顶点索引表示面的时候,记得经常会在调用顶点时顶点的索引要减1.
3.当从其他程序中,转换的时候,(比如把VC6.0的代码转换到VC2005的代码,可能原来程序是WINDOWS程序,而转换后应该是控制台程序),就会出现error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup的错误,那么更改Linker->System->SubSystem 即可.
4.在用ofstream输出的时候,经常发生错误error C2065: 'ofstream' : undeclared identifier 主要原因是忘记写using namespace std;
5.在用到stl的vector等容器时,会出现如下错误:
error C2143: syntax error : missing ';' before '<'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
是因为在用到vector的地方没加 using namespace std;
上面的错误也可能是因为在用到一个类的时候,虽然include了该文件,但是仍然要在前面说一下:
class CLand;
6.在使用vector<someclass>时,如果使用push_back函数出现异常,很可能是你自己写的someclass没有写拷贝构造函数!另外,如果是自己写的类someclass,这个类的析构函数一定要是虚函数。
7.error C2259: cannot instantiate abstract class
是由于自己在基类中声明了纯虚函数,而在继承类中没有对其实现。
8.在调用DLL时,常点“取消”或“下一步”后就会出现内存出错等等错误,原因是下面代码中,CSheet sheet(_T("name"));要有_T()
extern "C" __declspec(dllexport) void LightCalShow()
{
HINSTANCE save_hInstance = AfxGetResourceHandle();
AfxSetResourceHandle(theApp.m_hInstance);
AFX_MANAGE_STATE(AfxGetAppModuleState());
CSheet sheet(_T("name"));
sheet.DoModal();
AfxSetResourceHandle(save_hInstance);
}

被折叠的 条评论
为什么被折叠?



