175. Template

Question.9

Two approaches to a generic sort:

C approach -- void*:

void sort(void* arr, int n, int elem_size,
         int (*cmp)(const void*, const void*));

C++ approach -- template:

template<typename T>
void sort(T* arr, int n);

What advantages does the template version provide?

Need Help? Refer to the Quick Guide below

Select Answer