In continuation to my previous question, I would like to ask the following :
Given a C++ function having a new statement in it but not returning anything explicitly (i.e. with a return statement), should it also always have a delete?
If no, could you please give me an example.
It doesn’t have to explicitly return the newly-created object, but it should pass it to something else in some way. Possible scenarios include:
Example:
Examples:
Example:
Example: