Something like this:
std::stringstream out;for (int i = 0; i< 10; i++){ out << "X"; cout << "\r" << "[" << out.str() << "]";}
The sneaky bit is the carriage return character "\r" which causes the cursor to move to the start of the line without going down to the next line.