Is there a difference between defining member functions for a template class inside the class declaration versus outside?
Defined inside:
template
There's no difference, aside from having to type more. That includes the template
bit, the inline
and having to use more "elaborate" names when referring to the class. For example
template class A {
A method(A a) {
// whatever
}
};
template inline A A::method(A a) {
// whatever
}
Note that when the method is defined inside you can always omit the template parameter list
when referring to A
and just use A
. When defining it outside, you have to use the "full" name in the return type and in the name of the method (but not in the parameter list).