I have a C++ function that checks and swaps pointer data. My problem is that once the variables go into the function it works properly with no issues, but whenever I return from the function it seems as if it was never entered as the vales still hold the same information from before entering the function.
Below is a code snippet.
bool Swap(int* pComp, int* pNew)
{
pComp = pNew;
return true;
}
Any advice is greatly appreciated
Your function doesn’t do anything, as it only affects the local pointer variables that exist within function scope. If you’re trying to swap two pointers, you would have to do: