-
Defining class methods
I know you are supposed to put the class declaration in a .h file and put the definition in a .cpp file but is it wrong to define small class methods in the .h file with the declaration? MS VC++ Toolkit 2003 doesn't seem to mind but should I avoid doing it?
When I say small I mean something like this:
Code:
class whatever{
int x;
public:
int get_x(){
return x;
}
};
-
There is nothing wrong with doing that I believe. It is more a stylistic issue than a correctness issue. Because if you are defining inline functions and such you can only define them in the header.
-