头文件
#ifndef H_MODEL_UTIL
#define H_MODEL_UTIL
#include "Mesh.h"
Mesh *kingHigh;
void InitModel();
#endif
源文件
#include "stdafx.h"
#include "ResourceLoader.h"
#include "ModelUtil.h"
void InitModel()
{
::kingHigh = new Mesh();
}
编译器输出:
1>Game.obj : error LNK2005: "class Mesh * kingHigh" (?kingHigh@@3PAVMesh@@A) already defined in Cube.obj
1>ModelUtil.obj : error LNK2005: "class Mesh * kingHigh" (?kingHigh@@3PAVMesh@@A) already defined in Cube.obj
1>C:\Users\Anthony\Desktop\C++ Learning\Extra\Rubiks Chess\Debug\Rubiks Chess.exe : fatal error LNK1169: one or more multiply defined symbols found
我正在尝试初始化一个全局变量,但我不断收到此错误。有简单的解决方案吗?