#include <iostream>
class AA {
public:
virtual int foo() = 0;
};
template<int p> class A : public AA {};
template<> class A<1> :public AA {
public:
int foo() {
return 1;
}
};
template<> class A<2> : public AA {
public:
int foo() {
return 2;
}
};
int main(int argc, char** argv){
A<1> a1;
A<2> a2;
AA* a3 = &a2;
std::cout << a1.foo() << std::endl << a2.foo() << std::endl << a3->foo() << std::endl;
return 0;
}