The following explicitly defined template function
compares two strings and returns a value indicating whether more than 5
% of the characters differ between the two strings:
#include <string.h> int approximate(char *first, char *second) { if (strcmp(first,second) == 0) return 1; // strings are identical double difct=0; int maxlen=0; if (strlen(first)>strlen(second)) maxlen=strlen(first); else maxlen=strlen(second); for (int i=0; i<=maxlen ; ++i) if ( first[i] != second[i] ) difct++; return int((difct / maxlen) <= .05 ); }
Given this definition, the function call: approximate("String
A","String B"); invokes the explicitly defined function
above, and no template function is generated.