最好不要在头文件中定义变量,如果被多个.cpp文件包含,就会报上述错误。如果添加了static,该变量只在当前头文件可见。 When modifying a variable or function at file scope, the static keyword specifies that the variable or function has internal linkage (its name is not visible from outside the file in which it is declared).
COLORREF arColors[5] =
{
RGB(0,0,0),
RGB(255,0,0),
RGB(0,255,0),
RGB(0,0,255),
RGB(255,255,255)
};
When modifying a variable or function at file scope, the static keyword specifies that the variable or function has internal linkage (its name is not visible from outside the file in which it is declared).