英文版第八页: Programmers often insert print statements during debugging。 Such statements should always flush the stream。Forgetting to do so may cause output to be left in the buffer if the program crashes,leading to incorrect inferences about where the program carshed。 谁能举例说明一下或者详细解释一下。 manipulator has the effect of writing a newline to the output and flushing the buffer associate with that device。这句也不是太理解,endl能换行我知道,但是flushing the buffer associate with that device 这句我不是太明白,不是他的意思而是怎么工作的。 第十九页: #include <iostream> int main() { int sum=0,value; while(std::cin>>value)//这句怎么解释std::cin>>value返回的是std::cin怎么来判断是真还是假啊, sum+=value; std::cout < <"Sum is: " < <sum < <std::endl; return 0; } 第二十一页: Compilers usually aren't picky about header file names,but IDEs sometimes are.这句话怎么理解(不是翻译)谁能详细解释一下或举下例吗?
flush的意思是:对于输入流,读入所有缓冲中的内容,对于输出流,则把输出流中的内容都送到目的地flushing the buffer associate with that device ,就是把这个设备上的缓冲完全请出去。诸如,流不一定是屏幕和键盘,例如文件流,flush可能就是把输出缓冲写入到文件这个device中去
Programmers often insert print statements during debugging. Such statements should always flush the stream. Forgetting to do so may cause output to be left in the buffer if the program crashes, leading to incorrect inferences about where the program crashed.
程序员经常在调试过程中插入输出语句,这些语句都应该刷新输出流。忘记刷新输出流可能会造成输出停留在缓冲区中,如果程序崩溃,将会导致程序错误推断崩溃位置。 flushing the buffer associate with that device。应该是刷新缓冲区的意思。 if(!cin)来检查对错。 类类型存储在一个文件中,其文件名如同程序的源文件名一样,由文件名和文件后缀两部分组成。通常文件名和定义在头文件中的类名是一样的。通常后缀是 .h,但也有一些程序员用 .H、.hpp 或 .hxx。编译器通常并不挑剔头文件名,但 IDE 有时会。 看来你还是不怎么理解,书上说的什么。如果你要中英互译的电子书,我有,给我你的电子邮箱。