+ 2

Guys , how can i use char* array into a find maximum function using template?

Template with char * array

14th Jun 2019, 1:59 PM
David Bukedi Diela
David Bukedi Diela - avatar
4 Respuestas
+ 2
The program that i have to design: A function template to find max from different data types such as int,char, float, double , long , char* It says that i have to pass an array as argument by using type template argument and pass the size of the array by using non-type template (i think here integer) arguments And also to find max in a char* , i need to use function overloading
14th Jun 2019, 10:01 PM
David Bukedi Diela
David Bukedi Diela - avatar
+ 2
I did it for int, char, float , double , long but char* I'm lost like completely
14th Jun 2019, 10:01 PM
David Bukedi Diela
David Bukedi Diela - avatar
+ 1
template <class T> class tryThis{ private: T* array; }; you can’t template a char* array because it’s set as char. Just use the template variable and it will adapt to what you pass in.
14th Jun 2019, 3:41 PM
Jackson O’Donnell
+ 1
Char* is normally a character array. If you have an array of these it will be a matrix
14th Jun 2019, 10:06 PM
Jackson O’Donnell