What is the difference in getting a value through aMap[key] and aMap.at(key) in C++?
What is the difference in getting a value through aMap[key] and aMap.at(key) in C++?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In C++11
map::atexists (who knew?).It throws an exception if the key doesn’t exist,
findreturnsaMap.end()if the element doesn’t exist, andoperator[]value-initializes a new value for the corresponding key if no value exists there.