回复歌尽桃花:The side effect is to output the right hand variable and the expression produces a value that is an output stream (technically its a reference to an output stream, but it amounts to the same thing). This value can be used again as the left hand size of a <<. So to call the put functions 3 times as before:- cout << "x = " << x << "\n"; because the << operator is evaluated left to right. It take a little getting used to for a FORTRAN programmer, but after a while you get used to seeing this as a cout object with a stream of values flowing into it. As you might expect, input simply reverses the sign on the flow, so to read 3 numbers from the input stream and store them in x, y, z:- cin >> x >> y >> z;
回复歌尽桃花:其实可以形象地来理解这个问题,你可以把箭头的方向看作是数据流动的方向 比如,>>就是数据从左侧流动到右侧,也就是从左侧流出,那么在输入输出过程中,cin或者cout位于我们的左侧,而只有cin是流出(从键盘流出),cout是流入(流入到屏幕) 那么很自然的就是 int n; cin>>n; // 数据从键盘流入变量n cout<<n;// 变量n的数据流入到屏幕 这样记忆就很容易了 很抱歉回答晚了,希望可以帮助到你
本课程是《我的第一本C++书》的部分精彩章节选集通过本课程和这本书,你可以了解到C++中最核心最重要的内容,可以说,这是一个快速入门C++的课程。都说C++很难,可很多读者在看完这本书后,都有一种恍然...