[英]How can QString::toInt() convert a string that's not numeric?
我正在阅读我的一本教科书,它在解释它引入的代码方面做得很差。 这里的示例代码:
int choice;
QString response;
do {
cout << READ << ". Read data from a file.\n"
<< ADD << ". Add items to the Library.\n"
<< FIND << ". Find and display an item.\n"
<< REMOVE << ". Remove an item from the Library.\n"
<< SAVE << ". Save the Library list to a file.\n"
<< LIST << ". Brief listing of Library items.\n"
<< QUIT << ". Exit from this program.\n"
<< "Your choice: " << flush;
response = cin.readLine();
choice = response.toInt();
} while(choice < READ or choice > QUIT)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.