Consider these classes.
class Base
{
...
};
class Derived : public Base
{
...
};
this function
void BaseFoo( std::ve
Taking Matt Price's answer from above, given that you know in advance what types you want to use with your function, you can declare the function template in the header file, and then add explicit instantiations for those types:
// BaseFoo.h
template
void BaseFoo( const std::vector& vec);
// BaseFoo.cpp
template
void BaseFoo( const std::vector& vec);
{
...
}
// Explicit instantiation means no need for definition in the header file.
template void BaseFoo ( const std::vector & vec );
template void BaseFoo ( const std::vector& vec );