#include <iostream>
struct A {
char foo() { return 'A';}
};
template<class T> struct B : public T {
virtual char foo() {return 'B';}
};
template<class T> struct C : public T {
virtual char foo() {return 'C';}
};
int main(int argc, char* argv[])
{
A* a = new A();
A* b = new B< A >();
A* c = new C< A >();
A* d = new B< C< A > >();
std::cout << a->foo() << b->foo() << c->foo() << d->foo();
return 0;
}
Login in to like
Login in to comment