To make a record of the nature of the syllabus, to think in terms of an outline, to have an expanded reading Supplement 1, consider what kind of connection and relationship the class can have: combination, delegate, inherit 2, combination: Object delegate containing other classes: Contains and expands, mostly public inheritance, is-a 3, virtual functions: Non-virtual functions, virtual function (virtual), pure virtual function (virtual, function behind =0) 3.1 virtual function: The virtual function of C + + is "runtime polymorphism", and the implementation of virtual function is provided in the parent class, which provides the default function implementation for subclasses. Subclasses can override the virtual functions of the parent class to implement the specialization of subclasses. 3.2 Pure virtual functions: Classes in C + + that contain pure virtual functions are referred to as "abstract classes". Abstract classes cannot use the new out object, only subclasses that implement the pure virtual function can be new out of the object. Pure virtual Functions in C + + are more like "provide only declaration, no implementation", are the constraints of a subclass, and are "interface inheritance". Pure virtual Functions in C + + are also a "run-time polymorphism". 3.3 Normal function: is statically compiled, no run-time polymorphism, only according to the pointer or reference to the "literal" class object, call their own normal function. The normal function is the "enforced implementation" provided by the parent class for the child class. Therefore, in an inheritance relationship, subclasses should not override the normal functions of the parent class, because the invocation of the function is related to the literal value of the class object. 4, Combination plus inheritance: subclasses inherit from the parent class, the subclass contains an object of another class, the parent class and the object which is constructed first? 5, delegation plus inheritance: can be said to be the basis for the realization of the observer pattern
geekband-Third week course Essentials record