C + + must use an initialization list

Source: Internet
Author: User
  1. In an inheritance relationship, the parent class has no default constructor
  2. Class type class member variable no default constructor
  3. Const type member variable
  4. Reference type member variable
Without the initialization list, the default initialization of all member variables before the object invocation constructor is performed, and then the contents of the constructor body are executed, which is not applicable for types that do not have default constructors and variables that need to be assigned when declared. The initialization list is part of the function declaration (the constructor Declaration) and is suitable for those variables that need to be assigned when declared.


From for notes (Wiz)

C + + must use an initialization list

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.