#include <cstdlib>
#include <iostream>
using namespace std;
class MyNodeA
{
public:
void SomeMethod(){cout<<"MyNodeA do sth"<<endl;}
};
class MyNodeB
{
public:
void SomeMethod(){cout<<"MyNodeB do sth"<<endl;}
};
template<class T>
class Test:public T
{
public:
~Test(){cout<<"Test 析构"<<endl;}
void SomeMethod(){
T* t = static_cast<T*>(this);
t->SomeMethod();
}
};
template<class T>void Do(Test<T>*p)
{
p->SomeMethod();
delete p;
}
int main(int argc, char *argv[])
{
Do(new Test<MyNodeA>);
Do(new Test<MyNodeB>);
system("PAUSE");
return EXIT_SUCCESS;
}