Recently in C + +, in the process of writing C + +, I feel that the biggest difference from C is not in the grammatical aspect but in the aspect of programming thinking, here is a record of personal thoughts.
- We write an abstract class that is intended to be used as a template in order to write various specific functions derived from the class. So an abstract class should not have private members at all, or even public members (as a template for derived classes). Write all the members protected :)
- Abstract class as a template is the most obvious, all the functions are written purely virtual function:)
- If a derived class is the lowest level, it is no longer inherited. Then private should not appear at all . Then almost all members should act as protected, for encapsulation and only exposing interfaces .
- The reason why we want to use C + + is to write classes. is to hide internal details and provide interfaces externally .
The programming idea of C + + realized in practical programming