Use of the explicit keyword in C + +

Source: Internet
Author: User

First, explicit effect:

In C + +, the explicit keyword is used to modify the constructor of a class, the class of a constructor that is decorated, the corresponding implicit type conversion cannot occur, and the type conversion can only be performed in a display way.

Second, explicit use precautions:

    • The explicit keyword can only be used on a constructor declaration inside a class.
    • The explicit keyword is used as a constructor for a single argument.
    • In C + +, the explicit keyword is used to modify the class's constructor, the class of the constructor being decorated, and the corresponding implicit type conversion cannot occur

Reference Blog: http://www.cnblogs.com/this-543273659/archive/2011/08/02/2124596.html

http://blog.csdn.net/chollima/article/details/3486230

Use of the explicit keyword in C + +

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.