Summary of basic knowledge of C + + template skills

Source: Internet
Author: User

1. If you want to access a type name that relies on template parameters, you should add the keyword typename before the type name.

2. Nested classes and member functions can also be templates.

3. The template version of the assignment operator does not replace the default assignment operator.

4, class template can also be used as template parameters, we call template template parameters.

5. Template arguments for templates must match exactly. Default template arguments for template arguments for templates are not considered when matching (such as std::d eque Allocator)

6. By displaying the call to the default constructor, you can ensure that the variables and members of the template are initialized with a default value, which also applies to variables and members of the built-in type.

7. For string, the type conversion (called decay) of the array to pointer (Array-to-pointer) occurs when and only if the parameter is not consumed in the actual argument deduction process.

Summary of basic knowledge of C + + template skills

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.