Jump to

v02-l2-modifObj

What solution does modify thename attribute of the Character object given in argument ?

struct Character {
    string name;
    int age;
};

void renameA(Character player, string newName) {
    player.name = newName;
}

void renameB(Character& player, string newName) {
    player.name = newName;
}

Character renameC(Character player, string newName) {
    player.name = newName;
    return player;
}

???