It looks like you're trying to treat &
as a variable name. It's not. Variable names consist only of letters, digits, and underscores.
Actually, in the function parameters, std::map<char, char>&
means that the type of the parameter is a "reference to std::map<char, char>
". Note that I said "reference to". That's what the &
means. It's part of the type and makes the parameter a reference parameter.
So you need to give your parameter a name and then use that name:
char Substitution::encodeChar(char a, std::map<char, char>& my_map){
return my_map[a];
}
We can read the parameter std::map<char, char>& my_map
as saying the my_map
is a "reference to std::map<char, char>
". Then, my_map[a]
accessing the key a
in that map.