您的位置:首页 > 其它

错误提示: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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐