[Thank you for the answers, and also sorry for not really understanding all, I guess I'm trying to run yet know know how to walk] If somebody could explain me what happens here, I would really appriciate it! (Just learning C++ and I couldn't really understand by myself/Mr.Google)
string luck;
int choice;
std::map< int, std::string > cookies {
{ 1, "Tomorrow is a day" },
{ 2, "Tomorrow can be cool" },
{ 3, "Summer is coming" }
};
while( cookies.size() ) {
cout << "What cookie do you want? [";
for_each( cookies.begin(), cookies.end(), []( std::map< int, string >::value_type & v ) { cout << v.first << ','; } );
cout << ']';
cin >> choice;
map< int, string >::iterator iter( cookies.find( choice ) );
if( iter == cookies.end() )
cout << "Sorry, that cookie has been taken" << endl;
else {
cout << iter->second << endl;
cookies.erase( iter );
}
If possible, please try to explain it to me like you're explaining how to walk to a child, I really only know the basics of the basic.
Thank you