在尝试编译代码时收到此链接器错误
错误LNK2001无法解析的外部符号“专用:静态类Engine :: Application * Engine :: Application :: s_Instance”(?s_Instance @ Application @ Engine @@ 0PEAV12 @ EA)
过去几天尝试修复它,但不幸失败,将不胜感激。
.cpp文件
namespace gameapp{
Application* Application::s_Instance = nullptr;
Application::Application()
{
BE_CORE_ASSERT(!s_Instance, "Application already exists!");
s_Instance = this;
}
}
.h文件
namespace gameapp
{
class GAME_API application
{
public:
inline static Application& Get() { return *s_Instance; }
private:
static Application* s_Instance;
}
}
其他.cpp文件,其中调用了函数(使用相同的名称空间)
Application& app = Application::Get();