"C + + problem grooming"

Source: Internet
Author: User

One, const and static differences

A 1.const defined constant will be freed after its scope is exceeded, and static will not.

2.const is initialized in the constructor, and static is initialized in the implementation of the class.

3.const belongs to a member, and static belongs to a class.

4. Declare the local variable with static, make it static storage (static data area), scope unchanged, declare the external variable with static so that it is valid only within this file. When using static for function definitions, the function is only valid within this file.

5.const: The value is immutable.

Reference: 72821452 and https://www.cnblogs.com/hellocby/p/3543989.html

Second, the template

1. Definition: A template is a tool to implement the code reuse mechanism, which can implement type parameterization, that is, the type is defined as a parameter, thus realizing the real code reusability. Template can be divided into two categories, one is a function template, the other is a class template.

2. Reference: https://www.cnblogs.com/sevenyuan/p/3154346.html

Third, dynamic library and Static library

1. Definition:

Static libraries: links to libraries are done at compile time.

Dynamic libraries: When the program is compiled, it is not connected to the target code, but is loaded only when the program is running.

2. Reference:

Https://www.cnblogs.com/findumars/p/7128511.html

Iv. polymorphic

1. Introduction:

2. Reference:

52939323

"C + + problem grooming"

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.