A) Say I have a pointer in my main, and I send that pointer to a function as an argument:
In that function:Code:int main() { Object *myPtr; someFunction(myPtr); }
Since it points to the same location in memory, does that delete the original object?Code:void someFunction(Object *somePtr) { somePtr = 0; delete somePtr; }
-----
B) How do I delete a pointer if it's a return type?
Is there a way to get that memory back for myPtr2?Code:Object* someFunction() { AnotherObject* myPtr2; return myPtr2; }