Study day 50

Time:2021-1-27

C++

  1. Derived classes
    1. Classes are not isolated from each other. There are parent classes and subclasses, that is, inheritance classes
    2. Parent class is also called base class and superclass
    3. Subclasses are also called derived classes
    4. Inheritance is one of the core of object-oriented programming
  2. The order in which constructors are called when derived class objects are defined
    1. First, define the parent class, define the common member variable function in the parent class, and build a new class by inheriting the parent class, that is, the subclass
    2. When defining a subclass object, it is necessary to call the constructor of the parent class and subclass, execute the constructor of the parent class first, and execute the subclass function later
  3. Public, protected, private, and access rights
    1. Public — public — can be accessed by any entity
    2. Protected — protected, between public and private, only the member functions of this class or subclass are allowed to access
    3. Private — for private use, only functions of members of this class are allowed to access
    4. The subclass inherits the parent class by public, and does not change the access permission of the parent class
    5. If the parent class is private, the subclass can’t access it. No matter through public, protected or private inheritance, the subclass can’t get access to the parent class
    6. All withIf the parent class wants the subclass to be able to access, it is set to protected, public, and private
  4. Function masking
    1. Using — to make the functions with the same name of the parent class visible in the subclass, that is, to make the functions with the same name of the parent class available in the subclass in an overloaded way
    2. By default, a subclass has a function with the same name as the parent class, so the subclass cannot access the function with the same name of the parent class, that is, the subclass replaces the function with the same name in the parent class. Using is the solution to this problem,
    3. The reference of using is mainly used to call the overloaded version of the parent class
    4. If you use — parent class:: function name — in a subclass, you can also call a function with the same name of the parent class. This is a mandatory call

Recommended Today

Jpg learning notes 2 (with complete code)

We have got the data that need to compress RGB from BMP. We need to transform the original data from RGB domain to YCbCr domain, and then down sample the YCbCr data. For students who don’t need to read the article, the source code is given here directly.https://github.com/Cheemion/JPEG_COMPRESS Image reference “compressed image file formats, JPEG, […]