Contrary to some answers, there are differences in the two practices.
If you put the implementation in a class declaration, the method will automatically be marked as inline
. For very short methods like wrappers this is a very useful feature .
.cc
, ( ) . , , , . , , , . :
class A;
class B {
public:
A method1();
void method2(A* a);
void method3(A& a);
};
#include "decl_of_class_A.h"
A B::method1() { }
, test.h
.cc
A
, test.cc
, .cc
. B
.
: , : , inline
.
Omnifarious : , , ++. const
. , . , , - , :
Point p(10, 20);
Point q(0, 0);
q = p; // no assignment operator provided ==> error!
, const Point p(10, 20)
.