The programming idea of C + + realized in practical programming

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.