您的位置:首页 > 编程语言 > C语言/C++

C++ Primer 4th Notes - Chapter 1 Getting Started

2009-02-04 10:44 731 查看
1.1. Writing a Simple C++ Program
Exercise 1.2, 貌似用echo %ERRORLEVEL%只能看到在command line运行的程序的返回值。
 
1.2. A First Look at Input/Output
C++ does not directly define any statements
to do input or output (IO). Instead, IO is provided by the standard library.
A stream is a sequence of characters
intended to be read from or written to an IO device of some kind.
cin(object of type istream), cout, cerr,
clog(objects of type istream).
Most operating systems give us a way of
redirecting the input or output streams when we run a program. Using
redirection we can associate these streams with files of our choosing.
endl is a special value, called a
manipulator, that when written to an output stream has the effect of writing a
newline to the output and flushing the buffer associated with that device.
 
1.3. A Word About Comments
 
1.4. Control Structures
1.4.4. Reading an Unknown Number of Inputs
while (std::cin >> value)
The input operator (Section
1.2.2, p. 8)
returns its left operand. When we use an istream as a condition,
the effect is to test the state of the stream.
Operating systems use different values for
end-of-file. On Windows systems we enter an end-of-file by typing a control-z simultaneously
type the "ctrl" key and a "z." On UNIX systems, including
Mac OS-X machines, it is usually control-d.
 
1.5. Introducing Classes
Headers for the standard library are
enclosed in angle brackets (<
>). Nonstandard headers are enclosed in double
quotes (" ").
Exercise 1.24, 习题解答给出的答案是加了限制的,要求了相同的ISBN挨着输,否则难度在于不知道需要多少个Sales_item对象。能不能用vector来解决?
 
1.6. The C++ Program
Exercise 1.26, 也不知习题解答给出的答案对不。
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息