I have one question. Is it possible to delete a pointer with function? This is my example:
void deletePointer(auto* pointer)
{
delete pointer;
pointer = nullptr;
}
int main()
{
int value = 5;
int* value_ptr = &value;
//Some code
deletePointer(value_ptr);
return 0;
}
And it doesn't work. I also tried adding "inline" keyword to function and with lambda.
auto deletePointer = [&](auto* pointer) -> void
{
delete pointer;
pointer = nullptr;
}
I think it only deletes pointer inside of function, lambda. Is it possible to make function that will delete pointer, which is passing to function?