
上QQ阅读APP看书,第一时间看更新
Summary
- The object-oriented model rests on the three cornerstones inheritance, encapsulation, and dynamic binding as well as the five relations instance, inheritance, aggregation, connection, and call.
- An object can be created as an instance of a class. A class consists of two types of members: methods (member functions) and fields (member variables). A member can be private, protected, or public. The methods of a class can be divided into constructors, inspectors, modifications, and one destructor.
- A class can inherit one or more, other baseclasses with its members. A method of the baseclass can be virtual, resulting in dynamic binding.
- An array can hold a sequence of objects. The classes of those objects have to have a default constructor or no constructor at all in order for the objects to be thoroughly initialized.
- With the help of pointers and classes, we can create a linked list, which is a very useful structure. With its help, we can construct a stack.
- We can overload the usual operators so they take objects as operands. However, we cannot affect the number of operands, nor the precedence or associativity of the operators.
- We can use the this pointer to access our own object and we can define functions as friends to a class.
- Exception handling is an elegant error handling method. When an error occurs, we throw an exception. The point in the exception may or may not be handled in another part of the code. In either case, we do not have to worry about that when the error occurs.
- We can define template classes, which are instantiated with suitable types when we instantiate objects. We can also define template functions that take parameters of different types.
- We can organize our classes, freestanding functions, and global variables into namespace.
- We can read from and write to text and binary files with the predefined classes
ifstream
andofstream
.