I usually only have the definitions of my classes inside a header if they are template classes.- If this is the case, i still like to split declaration and definition inside the header like that:
template<class T>
class Foo
{
public:
Foo();
void fooFunc();
};
template<class T>
Foo<T>::Foo()
{
}
template<class T>
void Foo<T>::fooFunc()
{
}
that code also compiles. But If I remove the template:
class Foo
{
public:
Foo();
void fooFunc();
};
Foo::Foo()
{
}
void Foo::fooFunc()
{
}
i get a duplicate symbol error for Foos functions. I was very sure that this should work and am very surprised that it does not. Is this expected behaviour? If I add an inline before the definition it works too.