I think the code is self-explanatory:
MyClass* pointer = NULL;
changePointer( pointer );
if (pointer == NULL)
{
// it's entering here :(
}
void changePointer( MyClass* p)
{
MyClass* temp = NULL;
for (int i = 0; i < myContainer.size(); ++i)
{
p = &(myContainer[i]);
if (p == NULL)
{
// it's not entering here :)
}
}
}
The pointer is being passed by value, not by reference, so the original variable cannot be changed. You need to change the function signature to:
…and pass a pointer to the pointer:
You’ll need to make some corresponding changes in the body of the function, too.