Team LiB
Previous Section Next Section

Defined Terms


base class(基类)

A class that is the parent of another class. The base class defines the interface that a derived class inherits.


condition state(条件状态)

Flags and associated functions usable by any of the stream classes that indicate whether a given stream is usable. States and functions to get and set these states are listed in Table 8.2 (p. 288).

流类用于指示给定的流是否用的标志以及相关函数。表 8.2 列出了流的状态以及获取和设置这些状态的函数。

derived class(派生类)

A derived class is one that shares an interface with its parent class.


file mode(文件模式)

Flags defined by the fstream classes that are specified when opening a file and control how a file can be used. Listed in Table 8.3 (p. 297).

fstream 类定义的标志,在打开文件和控制文件如何使用时指定。表 8.3 列出了所有的文件模式。


Stream object that reads or writes a named file. In addition to the normal iostream operations, the fstream class also defines open and close members. The open member function takes a C-style character string that names the file to open and an optional open mode argument. By default ifstreams are opened with in mode, ofstreams with out mode, and fstreams with in and out mode set. The close member closes the file to which the stream is attached. It must be called before another file can be opened.

用来读或写已命名文件的流对象。除了普通的 iostream 操作外,fstream 类还定义了 openclose 成员。open 成员函数有一个表示打开文件名的 C 风格字符串参数和一个可选的打开模式参数。默认时,ifstream 对象以 in 模式打开,ofstream 对象以 out 模式打开,而 fstream 对象则同时以 inout 模式打开。close 成员关闭流关联的文件,必须在打开另一个文件前调用。


Types that are related by inheritance share a common interface. A derived class inherits properties from its base class. Chapter 15 covers inheritance.


object-oriented library(面向对象标准库)

A set of classes related by inheritance. Generally speaking, the base class of an object-oriented library defines an interface that is shared by the classes derived from that base class. In the IO library, the istream and ostream classes serve as base classes for the types defined in the fstream and sstream headers. We can use an object of a derived class as if it were an object of the base class. For example, we can use the operations defined for istream on an ifstream object.

有继承关系的类的集合。一般来说,面向对象标准库的基类定义了接口,由继承这个 基类的各个派生类共享。在 IO 标准库中,istreamostream 类是 fstreamsstream 头文件中定义的类型的基类。派生类的对象可当做基类对象使用。例如,可在 ifstream 对象上使用 istream 定义的操作。


Stream object that reads or writes a string. In addition to the normal iostream operations, it also defines an overloaded member named str. Calling str with no arguments returns the string to which the stringstream is attached. Calling it with a string attaches the stringstream to a copy of that string.

读写字符串的流对象。除了普通的 iostream 操作外,它还定义了名为 str 的重载成员。无实参地调用 str 将返回 stringstream 所关联的 string 值。用 string 对象做实参调用它则将该 stringstream 对象与实参副本相关联。

Team LiB
Previous Section Next Section