C ++ Primer 17, 18 Objects Object Programming Reading Notes

zhaozj2021-02-16  78

By putting data members in the public query base class we can put the initialization and access support restrictions in the local area, this is our choice.

The derived class is composed of its base class sub-object and the derived part of the derived non-static data member.

The base class pointer can only access the data member and member functions of the declaration or inheritance in this class including the virtual member function and the actual object that it might points to, declares a member function as the virtual only delays in the program execution, according to PQ Pointing the actual class type for the resolution process of the instance to be called

All derived class objects are referenced to this same single shared static member who derived how many classes from the base class _Text_File only exist if they are willing, we can access syntax by derived class objects to access syntax (quarter class static) member)

Finally, if a derived class wishes to access the private member of its base class, the base class must explicitly declare the derived class as a friend Friend 1. In order to pass one or more strengthenings to the constructor of the member object, we Through member initialization tables, we can also initialize the non-class data member using a member initialization table 2. In order to deliver one or more parameters to the base class constructor, we also use the member initialization table constructor's call order Always as follows: 1 Base class constructor If there are multiple base classes, the call sequence of constructor constructor is the order in which a class appears in the class is derived instead of the order in the member initialization table. We will discuss multi-inheritance in Chapter 18. Class object constructor If there are multiple member class objects, the call sequence of constructor constructor is the order in which the object is declared in the class, rather than they appear in the order of the member initialization table. 3. Derive class constructor

转载请注明原文地址:https://www.9cbs.com/read-15036.html

New Post(0)