错误提示:error LNK2001: unresolved external symbol "public: static int person::weight" (?weight@person@@
2012-06-21 17:35
537 查看
类中静态变量未初始化或初始化错误。(类中静态变量初始化方法:静态数据成员在类声明中声明,在包含类方法的文件中初始化.初始化时使用作用域操作符来指出静态成员所属的类.但如果静态成员是整型或是枚举型const,则可以在类声明中初始化!!!)
如:
头文件:class person
{
public:
person();
~person();
int Getheight();
int Getweight();
int height;
static int weight;
};
实现文件:#include "a.h"
int person::weight = 0; //静态成员初始化格式
person::person()
{
height = 100;
weight = 100;
}
错误提示:error LNK2001: unresolved external symbol "public: static int person::weight" (?weight@person@@2HA)
如:
头文件:class person
{
public:
person();
~person();
int Getheight();
int Getweight();
int height;
static int weight;
};
实现文件:#include "a.h"
int person::weight = 0; //静态成员初始化格式
person::person()
{
height = 100;
weight = 100;
}
错误提示:error LNK2001: unresolved external symbol "public: static int person::weight" (?weight@person@@2HA)
相关文章推荐
- 问题error LNK2001: unresolved external symbol "public: static class解决
- vc中的error LNK2001: unresolved external symbol "public: static错误解决
- error LNK2001: unresolved external symbol "public: __thiscall CWinAppEx::CWinAppEx(int)" (??0CWinApp
- 错误:error LNK2001: unresolved external symbol "public: __thiscall
- 关于 error LNK2001: unresolved external symbol "public: static class CString 错误处理
- error LNK2001: unresolved external symbol "public: int __thiscall CFtProtocolThread::getFnIds(class _STL::vector > &)" (?getFnId
- 【C++ static】关于 error LNK2001: unresolved external symbol "public: static class CString 错误处理
- error LNK2001: unresolved external symbol "public: int __thiscal
- 关于 error LNK2001: unresolved external symbol "public: static class CString 错误处理
- [Qt4]VS2010编译提示error LNK2001: unresolved external symbol "public: virtual struct QMetaObject等错误解决方案
- unresolved external symbol "public: static struct 错误的原因及解决方法
- error LNK2001: unresolved external symbol "public: static ... 解决一法
- VS2008 与Qt编程 出现.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall问题
- Google glog error LNK2001: unresolved external symbol "__declspec(dllimport) int fLI::FLAGS_XXXX 错误的
- error LNK2001: unresolved external symbol "public: __thiscall Point::~Point(void)" (??1Point@@QAE@XZ
- error LNK2001: unresolved external symbol "public: __thiscall CWinAppEx::CWinAppEx(int)" (??0CWinApp
- error LNK2001: unresolved external symbol "public: virtual enum TCPSError
- error LNK2001: unresolved external symbol \"public: __thiscall。。。
- error LNK2001: unresolved external symbol "public: static struct QMetaObject const QwtPlot::staticMe
- error LNK2001: unresolved external symbol "private: static