#include <stdio.h>
class TraitsBase{
protected:
TraitsBase() {}
void func1(){
printf("func1\n");
}
void func2(){
printf("func2\n");
}
public:
virtual void call() = 0;
};
template<class T> class Traits;
template<> class Traits<int> : public TraitsBase{
public:
virtual void call(){
func1();
}
};
template<> class Traits<float>: public TraitsBase{
public:
virtual void call(){
func2();
}
};
int main(){
Traits<int> i;
i.call();
Traits<float> f;
f.call();
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgoKY2xhc3MgVHJhaXRzQmFzZXsKcHJvdGVjdGVkOgogICAgCiAgICBUcmFpdHNCYXNlKCkge30KCiAgICB2b2lkIGZ1bmMxKCl7CiAgICAgICAgcHJpbnRmKCJmdW5jMVxuIik7CiAgICB9CiAgICB2b2lkIGZ1bmMyKCl7CiAgICAgICAgcHJpbnRmKCJmdW5jMlxuIik7CiAgICB9CnB1YmxpYzoKICAgIHZpcnR1YWwgdm9pZCBjYWxsKCkgPSAwOwp9Owp0ZW1wbGF0ZTxjbGFzcyBUPiBjbGFzcyBUcmFpdHM7CnRlbXBsYXRlPD4gY2xhc3MgVHJhaXRzPGludD4gOiBwdWJsaWMgVHJhaXRzQmFzZXsKcHVibGljOgogICAgdmlydHVhbCB2b2lkIGNhbGwoKXsKICAgICAgICBmdW5jMSgpOwogICAgfQogICAgCn07CnRlbXBsYXRlPD4gY2xhc3MgVHJhaXRzPGZsb2F0PjogcHVibGljIFRyYWl0c0Jhc2V7CnB1YmxpYzoKICAgIHZpcnR1YWwgdm9pZCBjYWxsKCl7CiAgICAgICAgZnVuYzIoKTsKICAgIH0KfTsKaW50IG1haW4oKXsKICAgIFRyYWl0czxpbnQ+IGk7CiAgICBpLmNhbGwoKTsKICAgIFRyYWl0czxmbG9hdD4gZjsKICAgIGYuY2FsbCgpOwogICAgCn0=