[ create a new paste ] login | about

Link: http://codepad.org/4HVBn9oJ    [ raw code | output | fork ]

C++, pasted on Apr 18:
#include <string>
#include <iostream>
using namespace std;

template<class T> class foo{
  public:
  string what();
};

template<> class foo<char>{
public:
  string what();
};

template<class T> string foo<T>::what(){
  return "foo of type T";
}

template<> string foo<char>::what(){
  return "foo of type char";
}

int main(){
  foo<int> f;
  cout << f.what() << endl;
}


Output:
1
2
Line 19: error: template-id 'what<>' for 'std::string foo<char>::what()' does not match any template declaration
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: