   Question about strings and chars
  I have been working on my pong game.  Now I am breaking up the code to put it in multiple files.  Everything was working fine until I took the Sprite class out.  Now I included strings in the Sprite.h file and the main file.  In the main when making a new sprite, in the constructor I put a string with the file name. Ex. "paddle.bmp"  Before with the sprite class in the main file this worked fine.  Now that its split up, it gave me an error message saying that "paddle.bmp" is a char[] and it should be a std::string.  I know I can probably solve this by making a global variable like const std::string PADDLE_FILENAME "paddle.bmp".  I just want to know why it stopped working now that I put the class into another file.   
  It might happen that, not having access to the definition of std::string (because you forgot to include <string>), the compiler does not know that char[] can be implicitly cast to std::string.EDIT: However, it is a bad thing to have string literals littered (pun intended) all about your code. The least you should do to have a maintainable code that you can modify later is to make the name a constant global variable.   ;  I did a #include <string> in the main file as well as the Sprite.h file.  I agree it is bad code practice and I plan on including const global variables for that as well as others later on.I'm just curious why it's not working now, so I could learn something from this.   ;  Yeah your probably using relative positions so when you changed the file, you changed the directory. Try putting the file in the root drive and then telling the app to look for it in "C:\\filename.bmp"   ;  They are all in the same folder as the entire project.  I noticed something interesting though.  There is an error message for the two lines initializing the 2 paddles but not for the ball.  Here is the include section of the code and then the paddle and ball initialization.#include "SDL/SDL.h"#include "SDL/SDL_image.h"#include "SDL/SDL_ttf.h"#include <string>// Include the following classes#include "SDL_Graphics.h"#include "SDL_Input.h"#include "Sprite.h"g_paddle1 = new Sprite(g_graphics,0,0,20,100,255,255,255,"paddle.bmp",10.0,710,375);    g_paddle2 = new Sprite(g_graphics,0,0,20,100,255,255,255,"paddle.bmp",10.0,20,375);    g_ball = new Sprite(g_graphics,0,0,20,20,255,255,255,"ball.bmp",5.0,375,375,5.0,5.0);The error says:In function `int SDL_main(int, char**)': no matching function for call to `Sprite::Sprite(SDL_Graphics*&, int, int, int, int, int, int, int, const char[11], double, int, int)'candidates are: Sprite::Sprite(const Sprite&)Sprite::Sprite(SDL_Graphics*, int, int, int, int, int, int, int, std::string, float, int, int, float, float)   Then the same for the g_paddle2 line and nothing for g_ball line.Did I make a mistake somewhere?   ;  I don't think the error has anything to do with strings: no matching function for call to`Sprite::Sprite(SDL_Graphics*&, int, int, int, int, int, int, int, const char[11], double, int, int)'candidates are: Sprite::Sprite( SDL_Graphics*, int, int, int, int, int, int, int,    std::string,  float, int, int, float, float) You seem to be missing two parameters.   ;  Not sure, but I think you are missing 2 parameters in the paddle defs. g_ball = new Sprite(g_graphics,0,0,20,20,255,255,255,"ball.bmp",5.0,375,375,5.0,5.0); has the last 2 5.0 parameters while the paddles do not. Is that important?;  The last two had to do with the velocity and the default value was 0.  Here is the code for that.Sprite::Sprite(SDL_Graphics* graphics, int imageX, int imageY, int width, int height, int transparentR, int transparentG, int transparentB, const std::string imageFileName, float deltaVelocity, int x, int y, float Vx=0, float Vy=0) : m_graphics(graphics),    m_imageX(imageX), m_imageY(imageY),    m_width(width), m_height(height),    m_deltaVelocity(deltaVelocity),    m_x(x), m_y(y), m_Vx(Vx), m_Vy(Vy){   m_image = m_graphics->load_image(imageFileName,  transparentR, transparentG, transparentB); }The only thing that I can see different is the SDL_Graphics*& or *, char - string, double - float.But it worked perfectly when I had the class and its functions in the same .cpp so I'm kind of a loss at why it would not work now.Edit - Ok, just adding the two 0.0 at the end of the paddle1 and paddle2 made it work.  Any ideas why it wouldn't accept a default value?Oh and thank you everyone who took the time to post and help me.   ;  Are the default parameters visible at the call location? Or, if you prefer: are they indicated in the function declaration, if the function definition is not visible from the call location?EDIT: to add more on this topic, how do default arguments work?When you call a function with default values, and you fail to supply one or more arguments, the compiler looks at the function definition/declaration to check if those arguments have default values. If they do, then it rewrites the code to look as if you called, and manually passed the default values for each argument (although this might be optimized away, but these are the general semantics).If the compiler cannot observe that some of the parameters have default values (or, simply, if you did not supply enough mandatory arguments), it will throw a fit and tell you that soe arguments are missing. This makes it necessary to indicate the default values of the arguments in the declaration of your function, because they must be visible from the calling point.   ;  1) omg I really hate this new theme2) you need to put the default parameters somewhere that can be seen by everyone who uses the function, i.e. in the header file.   