The problem is that at return line, wholenum is deallocated and do not exist anumore.
So the address your return contain unknown value.
The easiest solution is to return the int directly
int getNum()
{
int wholeNum;
cout << "Enter a number: ";
cin >> wholeNum;
return &wholeNum;
return wholeNum;
}