The compiler is complaining about my default parameters?

You have to specify the default values for the arguments only in the declaration but not in the definition.

 class pBase : public sf::Thread {
     // ....
     void setColor( int _color = -1 );
     // ....
 } ;

 void pBase:: setColor( int _color )
 {
     // ....
 }

The default value for an member function's argument can either go in declaration or definition but not both. Quote from ISO/IEC 14882:2003(E) 8.3.6

6) Except for member functions of class templates, the default arguments in a member function definition that appears outside of the class definition are added to the set of default arguments provided by the member function declaration in the class definition. Default arguments for a member function of a class template shall be specified on the initial declaration of the member function within the class template. [Example:

class C { 
    void f(int i = 3);
    void g(int i, int j = 99);
};

void C::f(int i = 3)   // error: default argument already
{ }                    // specified in class scope

void C::g(int i = 88, int j)    // in this translation unit,
{ }                             // C::g can be called with no argument

—end example]

According to the standard provided example, it should actually work the way you did. Unless you have done like this, you shouldn't actually get the error. I amn't sure why it actually worked in your case with my solution. Probably something visual studio related, I guess.


Alright! It worked (a bit weird though because it was working fine when i had the whole code in one file).

I also had this problem when I started moving code around into multiple files. The real problem was that I forgot to write

#pragma once

at the top of the header file, and so it was redefining the functions multiple times (each time the header file was being invoked from a parent file), this caused the redefinition of default parameter error.