template and function call -


hey i'm relatively new c++ , wondering if tell me why won't compile. errors "no matching function call 'search(int[10],int)'" , "template argument deduction/substitution failed" program supposed search int array number 5, char array 'm' , string array "nuts"

#include <iostream> #include <string> #include <cstring>  using namespace std;   template<class t> void search(t& a, t& b) { t temp = a; t temp2= b; int index=0; bool found = false; while((!found)) {     if(temp2==temp[index])     {         found = true;     }     else      {         index++;     } } if(found) {     cout << temp[index]      << "is located @ index: " << index << endl; } }   int main() { int intarray[10]={3,5,9,14,15,19,21,34,47,52}; char chararray[10]={'b','d','e','g','i','k','m','o','r','t'}; string stringarray[10]={"all","big","cats","eat","food","grapes","hats","kelp","nuts", "rats"};  search(intarray, 5); search(chararray, 'm'); search(stringarray, "nuts"); } 


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -