现在有一个程序,有一个头文件和两个源文件。头文件定义了一个变量Height,然后源文件开头都包含了这个头文件;
现在调试,出现
picture.obj : error LNK2005: "int Height" (?Height@@3HA) already defined in main.obj
Debug/拼图2_0.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
我在头文件在这个变量定义前加了extern,还是一样的错误。这个错误到底是怎么回事呢?我粗略学过作用域,不太理解