1.
A pointer allows us to pass potentially large amounts of data around at low cost: instead of copying the data we simply pass its address as a pointer value. The type of the pointer determines what can be done to the data through the pointer.
2.
Like a pointer, a reference is an alias for an object, is usually implemented to hold a machine address of an object, and does not impose performance overhead compared to pointers, but it differs from a pointer in that:
• You access a reference with exactly the same syntax as the name of an object.
• A reference always refers to the object to which it was initialized .
• There is no "null reference," and we may assume that a reference refers to an object.
3.
A reference is an alternative name for an object, an alias. The main use of references is for specifying arguments and return values for functions in general and for overloaded operators in particular.
4.
A class is a user-defined data-type .
A class consists of a set of members. The most common kinds of members are data members
and member functions .
A class is a namespace containing its members.
5.
C++ classes are a tool for creating new types that can be used as conveniently as the built-in types.
The fundamental idea in defining a new type is to separate the incidental details of the implementation (e.g., the layout of the data used to store an object of the type) from the properties essential to the correct use of it (e.g., the complete list of functions that can access the data). Such a separation is best expressed by channeling all uses of the data structure and its internal housekeeping routines through a specific interface .
6.
The public members provide the class’s interface and the private members provide implementation details. Members are accessed using . (dot) for objects and −> (arrow) for pointers.
7.
A struct is a class where members are by default public.
8.基本概念
类是对象的抽象,而一个对象则是其对应的一个 实例
9.基本概念
在面向对象程序设计方法中,对象是系统中用来描述客观事物的一个实体,它由 数据 和可执行的一组操作共同组成。
10.
除了可以通过对象名来引用静态成员,还可以使用引用 类名 静态成员。
11.
静态数据成员初始化必须在 类外 进行。
12.
A variable that is part of a class, yet is not part of an object of that class, is called a static member. There is exactly one copy of a static member instead of one copy per object, as for ordinary non-static members.
13.
By declaring a nonmember function a friend, the function can access the private part of the class declaration. That is, a function declared friend is granted access to the implementation of a class just like a member function but is otherwise independent of that class.
14.
In a(n) ____is-a______ relationship, an object of a derived class also can be treated as an object of its base class.
15.
A base class's ____protected______ members can be accessed only in the base-class definition or in derived-class definitions.
16.
A binary operator can be defined by either a non-static member function taking one argument or a nonmember function taking two arguments.
17.
A unary operator, whether prefix or postfix, can be defined by either a non-static member function taking no arguments or a nonmember function taking one argument.
18.
The name of an operator function is the keyword operator followed by the operator itself, for example, operator<<. An operator function is declared and can be called like any other function. A use of the operator is only a shorthand for an explicit call of the operator function.
虚函数:
19.
Virtual functions overcome the problems with the type-field solution by allowing the programmer to declare functions in a base class that can be redefined in each derived class. The compiler and linker will guarantee the correct correspondence between objects and the functions applied to them.