Nov 15, 2015 at 3:14pm
I am trying to pass in the same array with different data types using template, I do not see the issue Please help
1 2 3 4 5 6 7 8 9 10
|
int main() {
int arr[5] = { 4, 1, 13, 3, 2 };
double arr[5] = { 1.1, 4.1, 8.1, 5.2, 2.3 };
string arr[5] = { "the", "student", "is", "in", "class" };
cout<<maxFunction<double>(arr)<<endl;//getting an error does //not match argument list
cout<<maxFunction<int>(arr)<<endl;
system("pause");
return 0;
|
Last edited on Nov 15, 2015 at 3:15pm
Nov 15, 2015 at 3:22pm
How is this maxFunction declared ?
Also you cannot have more than one variable with the same name.
Nov 15, 2015 at 7:10pm
Thanks,
Can i pass a string into the same function in hopes to alphabetize it or should i make a separate function for that
Last edited on Nov 15, 2015 at 7:12pm
Nov 15, 2015 at 8:05pm
You need a seperate function for that. maxFunction accepts only arrays.