#include <iostream>
using namespace std;
template <class T>
class MyClass {
public:
void func1(){
cout<<"default: func1"<<endl;
}
void func2(){
cout<<"default: func2"<<endl;
}
private:
T haha;
};
template <>
void MyClass<double>::func1() {
cout<<"special: func1"<<endl;
}
int main()
{
MyClass<int> intclass;
intclass.func1();
intclass.func2();
MyClass<double> doubleclass;
doubleclass.func1();
doubleclass.func2(); // error 'class MyClass<double>' has no member named 'func2'
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnRlbXBsYXRlIDxjbGFzcyBUPgpjbGFzcyBNeUNsYXNzIHsKcHVibGljOgogICAgdm9pZCBmdW5jMSgpewogICAgY291dDw8ImRlZmF1bHQ6IGZ1bmMxIjw8ZW5kbDsKICAgICB9CiAgICB2b2lkIGZ1bmMyKCl7CiAgICBjb3V0PDwiZGVmYXVsdDogZnVuYzIiPDxlbmRsOwogICAgIH0KcHJpdmF0ZToKICAgIFQgaGFoYTsKfTsKCnRlbXBsYXRlIDw+CnZvaWQgTXlDbGFzczxkb3VibGU+OjpmdW5jMSgpIHsKICAgIGNvdXQ8PCJzcGVjaWFsOiBmdW5jMSI8PGVuZGw7Cn0KCmludCBtYWluKCkKewogICAgTXlDbGFzczxpbnQ+IGludGNsYXNzOwogICAgaW50Y2xhc3MuZnVuYzEoKTsKICAgIGludGNsYXNzLmZ1bmMyKCk7CgogICAgTXlDbGFzczxkb3VibGU+IGRvdWJsZWNsYXNzOwogICAgZG91YmxlY2xhc3MuZnVuYzEoKTsKICAgIGRvdWJsZWNsYXNzLmZ1bmMyKCk7ICAvLyBlcnJvciAnY2xhc3MgTXlDbGFzczxkb3VibGU+JyBoYXMgbm8gbWVtYmVyIG5hbWVkICdmdW5jMicKICAgIHJldHVybiAwOwp9Cg==