Function templates cannot be partially customized
The Type compiler of function template parameters can be inferred and omitted, but the return value type must be written.
# Include <iostream> # include <typeinfo> using namespace STD; Template <typename T> class type {public: static string name () {return typeid (t ). name () ;}}; template <> class type <char >{public: static string name () {return "char ";}}; template <> class type <bool> {public: static string name () {return "bool" ;}}; template <> class type <double> {public: static string name () {return "double" ;}}; template <> class type <int> {public: static string name () {return "int ";}}; template <typename T> class type <t *> {public: static string name () {return type <t >:: name () + "Pointer ";}}; // function template <typename T> string type (t) {return type <t>: Name ();} int main () {// function template advantages: cout <type (123) <Endl; cout <type (45.6) <Endl; cout <type () <Endl; cout <"-------------------------" <Endl; int A = 10; char B = 'K'; cout <type (A * 1.0) <Endl; cout <type (a <B) <Endl; cout <type (& A) <Endl ;}