What am I trying to do:
Write a specialized version of the template from the previous exercise for processing vector<const char*> and programs that use this specialization.
I wrote the program as follows:
template<typename T> int count(vector<T> tvec, const T &t); template<> int count(vector<const char *> tvec, const char *const &s) { int count = 0; for (auto c : tvec) if (c == s) { ++count; } return count; } template<typename T> int count(vector<T> tvec, const T &t) { int count = 0; for (auto c : tvec) if (c == t) { ++count; } return count; } cout << count(svec, "GUO");
but i get an error
deduced conflicting types for parameter 'const T' ('std::basic_string<char>' and 'char [4]')
I want to know how to handle this. and besides, in the template function it seems that the array can be changed to a pointer, why can't my program process it?
source share