0

I have been trying to create a template of the following function.

static void search(vector <Cleassname> c, string str);

i tried something like this in my .h file

template <typename T, typename U> static void search(vector <T*> c, U str);

and in my .cpp file i tried

template <typename T, typename U> void CLASS::search(vector <T*> c, U str){}

i declared vector vector_var and passing its address to the function using & wheneveer i call upon the fonction in main(), it says there no reference to such function.

CLASS::search(&vector_var, mystring);
  • I don't know what `vector` is in your last line, but I doubt that `&vector` is a `vector`. More likely a `vector*`. Also, why would you want to template `str`? – CompuChip Jun 28 '22 at 07:17
  • i have declared vector vector_var in my main. that's what i'm passing to my function like. CLASS:search(&vector_var, mystring). just passing the address to the pointer parameter. – sidiki camara Jun 28 '22 at 08:01
  • But, again, your function takes a vector of pointers to `T`, not a pointer to a vector of `T`s. – CompuChip Jun 28 '22 at 08:42

0 Answers0