There is not difference today. Sometimes you just have to put the function outside the body of your class declaration typically when you have two classes that use each other declaration: lets say we have class A and class B where A::display() calls B::some_method() and B::func() calls A::blahblah(). In this case you have to declare the method of the first class outside the class body after the declaration of the second class to be able to call the method of the second class. The second class of course can already see the functions of the class that was declared first.
class B;
class A
{
public:
void func1()
{
printf("%s\n", __FUNCTION__);
}
void func2();
private:
B* m_B;
};
class B
{
public:
void blahblah()
{
printf("%s\n", __FUNCTION__);
}
void blah()
{
m_A->func1();
}
private:
A* m_A;
};
void A::func2()
{
m_B->blahblah();
}
Note that if you put A::func2() to the .cpp file instead of the header, the ordering of the class declarations and the A::func2() declaration remains the same if you preprocess the .cpp file. Visual studio can for example inline functions even if they are put into .cpp files with its link time code generation feature in return for some more link time.