The fifth week of learning: covering and protecting members

  1. A derived class can define a member with the same name as a member of the base class, called an override .
    To access such members in a derived class, the default is to access the members defined in the derived class. To access the members defined in the base class in the derived class, use the scope resolution operator. (Generally speaking, base class derived classes do not define member variables with the same name)

2. protected members protected

  1. protected: Can be accessed by the following functions:
    ①Member function of the
    base class ②Friend function of the base class ③Member function of the
    derived class (this is more than private)

Guess you like

Origin blog.csdn.net/ZmJ6666/article/details/108578494