我有一个名为MODEL的类,其中驻留了public static int theMaxFrames。该类是在它自己的头文件中定义的。theMaxFrames由模型类中的一个类和一个函数set_up()访问,该函数也在模型类中。Render.cpp源文件包含一个函数,该函数调用Direct3D.cpp源文件中的函数,而后者又通过模型对象调用set_up()函数。这是这两个源文件和theMaxFrames之间的唯一连接。
当我尝试编译我的代码时,我得到以下错误消息:
1>Direct3D.obj :错误模型:未解析的外部符号"public: static int MODEL::theMaxFrames“(?theMaxFrames@LNK2001@@2ha)
1>Render.obj :错误模型:未解析的外部符号"public: static int MODEL::theMaxFrames“(?theMaxFrames@LNK2001@@2ha)
1>C:\Users\Byron\Documents\Visual工作室2008\Projects\xFileViewer\Debug\xFileViewer.exe :致命错误LNK1120: 1个未解析的外部变量
发布于 2009-08-08 14:10:50
这听起来很像您在类中声明了theMaxFrames,但您并没有为它提供定义。
如果是这种情况,您需要在某个.cpp中为其提供定义。
例如:
int MODEL::theMaxFrames;这个问题有一个常见问题解答:static data members。
https://stackoverflow.com/questions/1248941
复制相似问题