我试图创建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
的实例。
定义必须在一个翻译单元中,但它也可以通过头文件进入一个翻译单元。 –