#include <iostream>
using namespace std;
class Parent
{
public:
virtual void Printf()=0;
};
class Child1 : public Parent
{
public:
void Printf()
{
cout << "Child1::Printf()" << endl;
}
};
class Child2 : public Parent
{
public:
void Printf()
{
cout << "Child2::Printf()" << endl;
}
};
class Child3 : public Parent
{
public:
void Printf()
{
cout << "Child3::Printf()" << endl;
}
};
template<typename Type>
class DoWhatBase
{
public:
virtual Type* GetBase() = 0;
};
template<typename Type>
class Dowhat : public DoWhatBase<Type>
{
public:
Type* GetBase()
{
return new Type();
}
};
int main()
{
DoWhatBase<Child1> *q = new Dowhat<Child1>();
Parent *p = q->GetBase();
p->Printf();
return 0;
}