mercredi 13 juin 2018

c++ do I need to manually delete a void* pointer which is then pointing to another concrete type?

Assume I have a pointer void* p, then after some passing in and out of functions, let's say p is now pointing to int. Then do I need to manually delete as delete static_cast<int*>(p)?

In most places people say delete only happen when there is new. But in this case, it's not but does C++ itself remember to release that memory?

Aucun commentaire:

Enregistrer un commentaire