Quote:This generates a compile error due to the address symbol(&).
Character * ChooseName(){ string name; cout << "Enter the name you would like for your character.\n"; cout << "Name: "; cin >> name; Character * cptr = new Character(name); cout << "Your character, " << cptr->GetName() << ", has been created.\n"; return cptr;}
if (theCharacter == NULL) { system("cls"); theCharacter = ChooseName(); }
Another alternative, but less intuitive would be:
void ChooseName( Character * &theCharacter){ ... theCharacter = new Character(name); ...};,,,ChooseName(theCharacter);
This falls under passing by reference.
While somewhat obscured above, this may seem more recognizable:
typedef Character * CharacterPtr;void ChooseName(CharacterPtr & character){};