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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -