加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 静态结构链接器错误

发布时间:2020-12-16 10:39:01 所属栏目:百科 来源:网络整理
导读:我正在尝试在C中创建一个静态结构: static struct Brushes{ static HBRUSH white ; static HBRUSH yellow ;} ; 但它不起作用,我得到: Error 4 error LNK2001: unresolved external symbol "public: static struct HBRUSH__ * Brushes::white" 为什么? 我
我正在尝试在C中创建一个静态结构:

static struct Brushes
{
  static HBRUSH white ;
  static HBRUSH yellow ;
} ;

但它不起作用,我得到:

Error 4 error LNK2001: unresolved external symbol "public: static struct HBRUSH__ * Brushes::white"

为什么?

我的想法是能够在整个程序中使用Brushes :: white,Brushes :: yellow,而无需创建Brushes实例.

解决方法

你必须在某处定义静态成员,通常在.cxx文件中,例如:

HBRUSH Brushes::white;

原因是头文件没有定义,它只声明它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读