I've created a function using template, as shown in that answer , like this:
utilits.h
...
template<typename T> bool theres(T a, vector<T> b);
...
utilits.cpp
...
template<typename T> bool theres(T a, vector<T> b)
{
for(T& it : b)
if (it == a)
return 1;
return 0;
}
...
main.cpp
...
vector<string> registro(0);
...
int main ()
{
...
string nick = "far";
...
if(theres(nick, registro)) // <- Erro aqui
...
}
I get the following error:
undefined reference to 'bool theres<std::string>(std::string, std::vector<std::string, std::allocator<std::string> >)'