C++11 Templates Types -
template<int t> struct typereturn{ string type() { return "int";} }; int main() { cout << typereturn<int>::type << endl;}
"error: redeclared here ‘int t’ struct typereturn{"
this should work
#include<iostream> using std::cout; using std::endl; template<typename t> struct typereturn; template<> struct typereturn<int>{ static std::string type() { return "int";} }; int main() { cout << typereturn<int>::type() << endl;}
fyi, why works: http://www.cprogramming.com/tutorial/template_specialization.html
Comments
Post a Comment