August 2012
Intermediate to advanced
976 pages
30h 17m
English
When we specialize a function template, we must supply arguments for every template parameter in the original template. To indicate that we are specializing a template, we use the keyword template followed by an empty pair of angle brackets (< >). The empty brackets indicate that arguments will be supplied for all the template parameters of the original template:
// special version of compare to handle pointers to character arraystemplate <>int compare(const char* const &p1, const char* const &p2){ return strcmp(p1, p2);}
The hard part in understanding this specialization is the function parameter types. When we define a specialization, the function parameter type(s) must match the corresponding ...
Read now
Unlock full access