The difference between private and protected_study notes

First of all, these two are restrictors for accessing member permissions in the class.
Private is completely private, only you can access it, derived classes and outsiders can not access
protected is protected, only derived classes can access, the outside can not access
outside the class If you want to use the members of the class, you can only use public directly Types, protected and private are inaccessible, for outside the class, these two are exactly the same.

Understanding:
private can only be called by itself;
protected: related classes (derived classes) can also be used;
other outsourced classes cannot call their modified methods;

Guess you like

Origin blog.csdn.net/qq_40084325/article/details/112556665