Cpp_syntax _ constant

Source: Internet
Author: User

A constant is defined as the amount that will not be modified at runtime.

In C, constants are defined using # define. In C ++, since C ++ is compatible with C, # define in C can be used to define constants, you can also use the const in C ++ to modify the variable to make it a constant.

It can be said that the constant defined in C language is defined by # define, but the constant defined by # define does not have any type information, which may cause insecurity.

Constants in C ++ are defined using const, and constants in C ++ have type information, so they are safer.

 

 

Volatile:

Volatile is the opposite of Const. The variable is modified using volatile, which indicates that the variable is variable-prone and tells the compiler not to optimize the reading of the variable. If you want to reference a variable modified by volatile, you need to re-read the value of the variable, instead of using the value last read.

 

Cpp_syntax _ constant

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.