/////////////////////////////////////////////////////////////////// // fptr.cpp - Solution of MT#4-Q5 // // // // Shows how to create an array of function pointers holding // // pointers to instantiated template functions. // /////////////////////////////////////////////////////////////////// #include #include #include template std::string aFunc(const T& t) { std::ostringstream cvt; cvt << t; return cvt.str(); } template std::string bFunc(const T& t) { std::ostringstream cvt; cvt << t; return cvt.str(); } template std::string aFunc(const double&); template std::string bFunc(const double&); int main() { typedef std::string(*fptr)(const double &d); fptr fp[2] = { aFunc, bFunc }; std::cout << "\n " << fp[0](3.1415827); std::cout << "\n " << fp[1](0.3333333) << "\n\n"; return 0; }