pointer to pointer assignment

Dec 15, 2013 at 8:24pm
hi everyone

i have a problem with my texture class

1
2
3
4
5
6
private:
SDL_Texture * mTex;
...
public:
void SetTexture(SDL_Texture * tex);
...


1
2
3
4
void texture::SetTexture(SDL_Texture * tex)
{
    mTex = tex;
}


so as you see when someone uses this function. it will automatically assign a texture loaded by user to class private mTex

what i cant understand is when i run the program to test it i receive SIGSEGV error and debugger says mTex = tex; line is the problem.

I cant see the problem. why it is problematic and gives sigsegv error.
Last edited on Dec 15, 2013 at 8:42pm
Dec 15, 2013 at 8:47pm
Probably the instance of your class being referred to is invalid, so when you use the SetTexture function on the invalid instance, it crashes.
Dec 16, 2013 at 3:35pm
L B thx for your help firstly.

i found out i was including texture class at font and font at texture. it was the thing causes error although i dont know why it causes yet.

anyways thx again.
Topic archived. No new replies allowed.