It's not possible, because there is no provision for it in the C++ language definition. I'm not sure there is any "good" answer to why the language doesn't support a list of items for delete
, except for the fact that it's simpler to not do that.
You need to write one delete
for each variable. Of course, if you have many pointerX
, then you probably should be using an array instead, and use a loop to delete the objects.
Edit: Of course, if you are calling delete
in many places in your code, you are probably doing something wrong - or at least, you are not following the RAII principles very well. It's of course necessary to learn/understand dynamic allocation to have full understanding of the language, but you should really avoid calling both new
and delete
in your own code - let someone else sort that out (or write classes that do "the right thing")