The const -defined constants are freed after the function executes, and static constants defined by the statics are not freed when the function is executed. However, whether they are const or static, the content they define will be known to the
C + + primer in the top-level const and the underlying const previously did not understand the top-level const and the underlying const, this time to see the sense of understanding.First, theconst is a qualifier, and the value of the variable it
Const summary in C ++
I. Basic statements1. Const int r = 100;// Standard const variable declaration and initialization, because the default internal connection must be initialized, its scopeFor this file, the compiler directly replaces it with 100
1, initialization
The const object must be initialized if its value cannot be changed once it is created.
The initial value can be arbitrarily complex expressions:
const int i = Get_size (); Correct: run-time initialization
const INT j= 42; Correct,
In a normal non-const member function, the type of this is a const pointer to the class type. You can change the value that this is pointing to, but you cannot change the address saved by this. In the const member function, the type of this is a
The space of a constant defined by const is released after the function is executed, while the static constant defined by static is not released after the function is executed.
Static indicates static. Static member functions of a class. member
Keywords: const, const function, const variable, const after Function
1. bool FA (const A & A); here const indicates that variable A cannot be modified in the bool FA (const A & A) function.2. Const A & FB (int I); the return value of the const A &
Why use Const. Code written in symbolic constants is easier to maintain; pointers are often moved by side-reading, rather than by writing; many function parameters are read-only and not written. The most common use of const is as the bounds of the
In the C + + class definition, you can see a definition similar to the following:class List {private: * p_head; int length; ...... Public: intconst; BOOL Getnodeinfo (constintconst {...} BOOL Deletenode (constint index);
A very good analysis of the summary of the const, thank you, the original author : http://blog.csdn.net/zcf1002797280/article/details/7816977In a normal non-const member function, the type of this is a const pointer to the class type. You can change
Ansic allows you to declare constants, constants and variables, constants that cannot be changed, and modifiers with the keyword constFor example: const int Aint const AThe above two declarations are the same, we do not need to consider the order of
Difference between const before and after a function
1. Const Basics If the const keyword does not involve pointers, we can understand it very well. The following is a case involving pointers:Int B =500;Const int * A = & B; [1] Int const * A = &
Recently in reading C + + primer, recorded reading notes. Const keyword
When we want to use a variable and don't want to be changed, we can use const to define a variable. This variable becomes an immutable variable, approximately equal to a
Const char * CP;CP is a pointer to const char; CP is a pointer variable that points to a constant character. Note that CP is a pointer variable and points to const char, which means CP can point to other const char; note that CP points to const char,
C + + General const usage Notes1. Const-Decorated class member variablesProgram:#include usingnamespace std; class a{ public: A (int size): size (size) {}; Private : Const int SIZE;}; int Main () { A A (+);}Description(1)
From: http://blog.csdn.net/linyaoxin/article/details/3160977
Const int * a, int const * a, int * const A, difference, pointer array, array pointer, declaration and definition
Several confusing concepts are recorded hereI. ====== method declared in C
Const in C/C ++, constin
1. the const object must be initialized because the value cannot be changed once created.
Eg:
Const int I = GetSize (); // correct: runtime Initialization
Const int j = 42; // correct: initialization at compilation
J = 33; //
Overview:The source code of the C preprocessor handler, which runs before the compiler, usually begins with the symbol #.Also involves static, const knowledge points ... Some are similar to Java ... Some easily confuse t.t.Many of the chapters in
Const in C language has always been a pain point for beginners in C language. This is because const has different functions in different locations and has different roles in different scenarios. This leaves beginners confused. Today, I will study
I. Storage Area of C language programs
1. an executable program (binary file) is formed by C language code (text file). Three phases are required: compilation, assembly, and connection. In the compilation process, C language text files are used to
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.