No, this is not for TA is closed.
Also, as suggested in the comments, the base class destructor must be virtual. This is usually good practice, as you cannot guarantee that instances of your classes will be used only with shared pointers.
For it to work, you must at least change the following lines:
class TA { }; class TB : TA { };
Properly:
class TA { virtual ~TA() { } }; class TB : public TA { };
Those that are good as the following example are good:
class TA { virtual ~TA() { } }; class TB : public TA { }; TA *spta = nullptr; spta = new TB;
It basically depends on what good remedies are for you. It is legal, at least.
source share