我正在C++的一個介紹級別課程上進行測驗,我試圖理解一個問題。在搜索了互聯網並沒有得到答案之後,我就在這裏。 Which of the following function declarations will accept either cout or a file stream
object as its argument?
A. void output(fstream &outFile)
do {
std::cout << "Enter a valid name" << std::endl;
std::cin >> name;
} while (!validName(name) && std::cout << "It is not a valid name" << std::endl);
這是一個很好的做法,如果名稱無效,那麼我用這種方式回答一條線?