79159248

Date: 2024-11-05 13:19:11
Score: 1
Natty:
Report link

Even if this is long time ago I'd like to add perspective to this. One naïve way to make the compiler happy is to first build a pointer to base class and pass that one. The question is now if one wants that or not? It's a mess for the reason showed in the accepted answer. It will probably not hurt if you just want to delete + make it null.

Better options are available these days, e.g. pass a unique_ptr by value to transfer ownership. With legacy APIs where you need to make it work just be sure that you're not shooting yourself in the leg by blindly casting to baseclass to make the compiler happy.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: cvomake