"flush(cout)" flushes the output buffer!

The only way to "flush" standard input is:

cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');