Wow... you practiced a lot of concepts, and you are just learning to code!!!
I'm sure you will be a successful programmer (but you should know it needs a lot more practicing!)
But about your "getTranslation" function, I changed it a little to:
#include <algorithm>
#include <cctype>
/*...*/
string getTranslation (string text) noexcept(true)
{
map <char,string> morseKey;
morseKey ['A'] = ".-";
morseKey ['B'] = "-...";
morseKey ['C'] = "-.-.";
/*...*/
string translation {""};
std::transform(text.begin(), text.end(), text.begin(), toupper);
for (it: text){
translation += morseKey[it];
}
return translation;
}
As you may know, map is an associative array; it means you don't need to iterate over all of its element to find your interesting element. You should associate a key to its corresponding record. In your case you should associate a char (not a string) to a string; so you should define your "morseKey" as:
map <char, string> morseKey;
and when you want to associate a character such as 'A' to ".-" you should do something like:
morseKey ['A'] = ".-"; /*instead of morsKey["A"] = ".-" */;
also when you used "auto" in defining your "translation" variable, compiler will consider it as a "const char*". so you should explicitly define your "translation" variable as:
string translation {""};
In addition because our "morseKey" map contains just uppercase of alphabets, we should convert alphabet characters of "text" variable to uppercase. This can be done very easily by:
std::transform(text.begin(), text.end(), text.begin(), toupper);
but for using this command you should include two libraries:
#include <algorithm> /*for "transform" */
#include <cctype> /*for "touppper" */
Also you shouldn't consider "text" variable as rvalue any more (because we modify it) so I change your function delcarion to:
string getTranslation (string text) noexcept(true)
Finally you should just iterate over your "text" variable and find corresponding Morse value of each character and append it to your return value; This also can be done very easily by:
for (it: text){
translation += morseKey[it];
}
Have fun with programming!
My reply for your second edit:
I think your information is not enough; perhaps it's better to ask your question as a new question, and also provide it with more details, such as in which line you got this compile error or any other useful details that you may think it can be helpful.