M
Martin Magnusson
I have a problem with multiple definitions that I can't quite straighten
out.
I have a templated class defined inside a namespace, and I want to
create a function in that namespace that works on a specific instance of
the templated class.
Like this:
// file Numerical.hpp:
namespace Numerical
{
template<int N>
class Vector { ... };
Vector<3> convert( Vector<3> v )
{ ... }
}
However, when doing it like that I get complaints from gcc, during
linking, about multiple definitions of Numerical::convert. If I write
convert as a member function instead, it all works fine. The whole
Numerical::Vector class is defined in the hpp file. I'm pretty sure I
don't have any multiple includes, and that all of my header files have
the proper #ifndef guards.
What could be the problem?
out.
I have a templated class defined inside a namespace, and I want to
create a function in that namespace that works on a specific instance of
the templated class.
Like this:
// file Numerical.hpp:
namespace Numerical
{
template<int N>
class Vector { ... };
Vector<3> convert( Vector<3> v )
{ ... }
}
However, when doing it like that I get complaints from gcc, during
linking, about multiple definitions of Numerical::convert. If I write
convert as a member function instead, it all works fine. The whole
Numerical::Vector class is defined in the hpp file. I'm pretty sure I
don't have any multiple includes, and that all of my header files have
the proper #ifndef guards.
What could be the problem?