Jump to content
  • Advertisement
Sign in to follow this  
Kenny77

Order of Args in Class Cons.

This topic is 3817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does the order of the arguments in class constructors (or any function) matter? I have a class that accepts: (SDL_Surface*, SDL_Rect, int, bool), but it only compiled when I switched the int and the bool around: (SDL_Surface, SDL_Rect, bool, int). What's the deal?

Share this post


Link to post
Share on other sites
Advertisement
SDL_Surface != SDL_Surface*.

The order of arguments definitely does matter, and what you've told us so far doesn't make sense.

I have the feeling your compiler was complaining about something like the destructor being declared one way and defined another. This won't work, for example:

struct foo { // <-- class definition
foo( int, char ); // <-- function/constructor declaration
};
foo::foo( char, int ) { // <-- function/constructor definition
}


Since there is no function declaration corresponding to ( char, int ), only ( int, char ). The easiest way to figure out what exactly the problem you're encountering is, would be to post the relevant code that you expected to work that didn't -- so, the class definition, the constructor definition, and the line you're using to try and create an instance of your class with, presumably.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!