Requesting Affirmation [pointer 2 custom class]
Boy, that dictionary is paying off :)
Heres my problem:
I have a custom class I created called CTexture as well as a custom class called CSprite. What I need is for multiple CSprite classes to point to a SINGLE CTexture class.
Heres my two classes.
bool LoadTexture(char *filename, int width, int height, LPDIRECT3DDEVICE9 device);
I was just wondering if my line in RED is correct or not. I'm pretty sure it is and by cycling through the debugger abit it appears to do what I want it to do. However, since this wasn't my initial solution I just wanted to get a second opinion if this is proper or not.
bool SetTexture(CTexture &texture);
void NewFrame(int frameWidth, int frameHeight, int startPixelX, int startPixelY);
bool Draw(int frameNum, D3DXVECTOR3 position, LPDIRECT3DDEVICE9 device);
bool CSprite::SetTexture(CTexture &texture)
m_Texture = &texture;
My initial solution was:
But it was complaining about "=" because I didn't overload the "=" for CTexture class. If I created a "=" function and copied variables from texture to m_Texture that would create a copy and not a pointer right?
m_Texture = texture;
Because elsewhere in my code I have:
And it works fine.. seems like a similar circumstance except temp & m_FirstFrame are referring to a STRUCT while in the first case I had pointers to a CLASS.. Why does the first example require a & but the second case does not complain about a need for overload "=" operator.
temp = m_FirstFrame;
Is this because a class has private while everything in a struct is public?
Thnx for any clarification.