I'm currently developping some class to make my life simplier in SDL (My life haven't been really simpler since)
I have just create a classe named : Boutton, to create ... Boutton.
The class have 3 attributes :
[source lang="cpp"]char *b_t;SDL_Color b_ct;TTF_Font *b_p;[/source]
B_t and b_p are pointer. I have to destruct them or I will have a memory lack.
so I have added in my destructor the following line :
[source lang="cpp"]MISC_Bouton:: ~MISC_Bouton (){ TTF_CloseFont(b_p); delete(b_t);}[/source]
Now, I have to create a copy and an asign constructor,
My problem is, How I can do to do these
[source lang="cpp"] MISC_Bouton (MISC_Bouton const& other)MISC_Bouton& MISC_Bouton ::operator=(MISC_Bouton const& other)[/source])
I already had that kind of problem with SDL_Surface* in my windows class but there are a function to copy SDL_Surface (SDL_ConvertSurface()) so I was abled to copy the SDL_Surface in himself and not the adress.
So anyone knows something to copy a TTF_Surface and not the adress ?
Thanks
Show differencesHistory of post edits
#2Jabor
Posted 13 July 2012 - 08:34 AM
I'm currently developping some class to make my life simplier in SDL (My life haven't been really simpler since)
I have just create a classe named : Boutton, to create ... Boutton.
The class have 3 attributes :
[source lang="cpp"]char *b_t;SDL_Color b_ct;TTF_Font *b_p;[/source]
B_t and b_p are pointer. I have to destruct them or I will have a memory lack.
so I have added in my destructor the following line :
[source lang="cpp"]MISC_Bouton:: ~MISC_Bouton (){ TTF_CloseFont(b_p); delete(b_t);}[/source]
Now, I have to create a copy and an asign constructor,
My problem is, How I can do to do these
[source lang="cpp"] MISC_Bouton (MISC_Bouton const& other)MISC_Bouton& MISC_Bouton ::operator=(MISC_Bouton const& other)[/source])
I already had that kind of problem with SDL_Surface* in my windows class but there are a function to copy SDL_Surface (SDL_ConvertSurface()) so I was abled to copy the SDL_Surface in himself and not the adress.
So anyone knows something to copy a TTF_Surface and not the adress ?
Thanks
I have just create a classe named : Boutton, to create ... Boutton.
The class have 3 attributes :
[source lang="cpp"]char *b_t;SDL_Color b_ct;TTF_Font *b_p;[/source]
B_t and b_p are pointer. I have to destruct them or I will have a memory lack.
so I have added in my destructor the following line :
[source lang="cpp"]MISC_Bouton:: ~MISC_Bouton (){ TTF_CloseFont(b_p); delete(b_t);}[/source]
Now, I have to create a copy and an asign constructor,
My problem is, How I can do to do these
[source lang="cpp"] MISC_Bouton (MISC_Bouton const& other)MISC_Bouton& MISC_Bouton ::operator=(MISC_Bouton const& other)[/source])
I already had that kind of problem with SDL_Surface* in my windows class but there are a function to copy SDL_Surface (SDL_ConvertSurface()) so I was abled to copy the SDL_Surface in himself and not the adress.
So anyone knows something to copy a TTF_Surface and not the adress ?
Thanks
#1Jabor
Posted 13 July 2012 - 08:33 AM
I'm currently developping some class to make my life simplier in SDL (My life haven't been really simpler since)
I have just create a classe named : Boutton, to create ... Boutton.
The class have 3 attributes :
[source lang="cpp"]char *b_t;SDL_Color b_ct;TTF_Font *b_p;[/source]
B_t and b_p are pointer. I have to destruct them or I will have a memory lack.
so I have added in my destructor the following line :
[source lang="cpp"]MISC_Bouton:: ~MISC_Bouton (){ TTF_CloseFont(b_p); delete(b_t);}[/source]
Now, I have to create a copy and an asign constructor,
My problem is, How I can do to do these
[source lang="cpp"] MISC_Bouton (MISC_Bouton const& other)MISC_Bouton& MISC_Bouton ::operator=(MISC_Bouton const& other)[/source])
I already had that kind of problem with SDL_Surface* in my windows class but there are a function to copy SDL_Surface (SDL_ConvertSurface()) so I was abled to copy the SDL_Surface in himself and not the adress.
So anyone knows something to copy a TTF_Surface and not the adress ?
Thanks
I have just create a classe named : Boutton, to create ... Boutton.
The class have 3 attributes :
[source lang="cpp"]char *b_t;SDL_Color b_ct;TTF_Font *b_p;[/source]
B_t and b_p are pointer. I have to destruct them or I will have a memory lack.
so I have added in my destructor the following line :
[source lang="cpp"]MISC_Bouton:: ~MISC_Bouton (){ TTF_CloseFont(b_p); delete(b_t);}[/source]
Now, I have to create a copy and an asign constructor,
My problem is, How I can do to do these
[source lang="cpp"] MISC_Bouton (MISC_Bouton const& other)MISC_Bouton& MISC_Bouton ::operator=(MISC_Bouton const& other)[/source])
I already had that kind of problem with SDL_Surface* in my windows class but there are a function to copy SDL_Surface (SDL_ConvertSurface()) so I was abled to copy the SDL_Surface in himself and not the adress.
So anyone knows something to copy a TTF_Surface and not the adress ?
Thanks