Reputation: 8280
I have a class with this function:
void Render(SDL_Surface *source,SDL_Surface *destination,string img)
{
SDL_Rect offset;
offset.x = m_x;
offset.y = m_y;
source = IMG_Load(img);
offset.w = source->w;
offset.h = source->h;
}
For some reason though even with include <string>
at the top of the header file it won't allow it. I get:
Identifier, "string" is undefined.
Im passing the data like this on my main file:
btn_quit.Render(menu,screen,"button.png");
When i execute i get :
'Button::Render' : function does not take 3 arguments
But this site says string
is the correct syntax for the data type (at the bottom): http://www.cplusplus.com/doc/tutorial/variables/
Can some one explain what I am doing wrong ?
Upvotes: 0
Views: 1028
Reputation: 45410
I may suggest you change Render function to below:
void Render(SDL_Surface *source,SDL_Surface *destination,const std::string& img)
{
SDL_Rect offset;
offset.x = m_x;
offset.y = m_y;
source = IMG_Load(img.c_str());
offset.w = source->w;
offset.h = source->h;
}
Upvotes: 3