Код: Выделить всё
#include <iostream>
template <typename T>
class My
{
public:
My()
{}
virtual ~My()
{
b_func();
}
virtual int b_func()
{
std::cout << "HI!\n";
return 0;
}
virtual void call()
{
this->b_func();
}
};
template <typename T>
class S : public My<T>
{
public:
virtual int b_func()
{
std::cout << "Bye!\n";
return 0;
}
};
int main()
{
// My<int>* p = new My<int>();
My<int>* p = new S<int>();
p->call();
delete p;
return 0;
}