作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在 C++ 方面并不太胜任,这个编译器错误对我来说毫无意义。下面一行调用标题所示的编译错误:
m_SunTexture = LudoTextureManager::GetInstance()->GetTextureData(hardcoded.c_str()).m_Texture;
m_SunTexture 在我的头文件中定义为
IDirect3DTexture9 *m_SunTexture;
在我的头文件的私有(private)部分。为什么是这样!这对我来说毫无意义。
根据要求,这里有更多代码。 m_SunTexture 正在这个函数中被调用
void Sun::DrawSun()
{
std::wstring hardcoded = L"..\\Data\\sun.jpg";
m_SunTexture = LudoTextureManager::GetInstance()->GetTextureData(hardcoded.c_str()).m_Texture;
//more code here, cut off because it's useless for this.
}
DrawSun在头文件中定义为:
static void DrawSun();
在我的头文件的公共(public)部分下。
最佳答案
我猜第一行代码在一个静态函数中,它指的是非静态成员“m_SunTexture”。
参见 this想要查询更多的信息。本质上,静态函数没有“this”指针,因此引用非静态成员(属于类的每个实例)没有任何意义。
关于c++ - 非法引用非静态成员 'Sun::m_SunTexture',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1698388/
我在 C++ 方面并不太胜任,这个编译器错误对我来说毫无意义。下面一行调用标题所示的编译错误: m_SunTexture = LudoTextureManager::GetInstance()->Ge
我是一名优秀的程序员,十分优秀!