views:

151

answers:

1

Hi, I am not overly competent in C++ and this compiler error is just making no sense to me. The following line calls the compiler error shown in the title:

m_SunTexture = LudoTextureManager::GetInstance()->GetTextureData(hardcoded.c_str()).m_Texture;

where m_SunTexture is defined in my header file as

IDirect3DTexture9 *m_SunTexture;

in the private section of my header file. Why is this! This makes no sense to me.

Here is more code, as requested. m_SunTexture is being called in this function

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 is defined in the header file as:

static void DrawSun();

under the public section of my header file.

+5  A: 

I'm guessing that the first line of code is in a static function, which is referring to the non-static member "m_SunTexture".

See this for more information. Essentially, static functions don't have a "this" pointer, so referring to non-static members (which belong to each instance of the class) doesn't make any sense.

Justicle
This makes a lot of sense actually. I'm not sure why this funciton was static in the first place. Thank you!
4501
No probs, thanks for updating the question with the function declaration :-)
Justicle