0
/\
1 2
/\ \
3 4 5
/\
6 7
0
/\
2 1
/\
3 4
class DeleterBase {
public:
DeleterBase() {};
virtual ~DeleterBase() {};
};
template<class T>
class Deleter : public DeleterBase
{
public:
explicit Deleter(T* ptr) : ptr_(ptr) {};
virtual ~Deleter() override {
delete ptr_;
}
private:
T* ptr_;
};
DeleterBase * hldr = new Deleter<A>(new A());
delete hldr;