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

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -