I. Possible combinations:
(1) const char * P
(2) Char const * P
(3) char * const P(4) const char ** P
(5) Char const ** P
(6) char * const * P
(7) Char ** const P
Of course, there are several cases of inserting a const in (5), (6), and
One, possible combinations:(1) Const CHAR*P(2) Char Const*p(3) Char *const p(4) const char **P(5) Char Const**p(6) Char *const *p(7) Char **const pOf course, in (5), (6), (7) and then insert a const in a number of cases, but the analysis of the
Constraints for assigning values according to ansi c:
1. Both operands are pointers to compatible types with or without delimiters.
2. the type pointed to by the Left pointer must have all the qualifiers of the type pointed to by the right
The use of const in C + + is very extensive, different location to use the meaning is not the same, so want to write an article to make a summary.
First of all, it is clear that the const is the basic meaning of "unchanging", but the same does not
Const thinking
1. What is const?A common type is a type described by the Type modifier Const. The values of variables or objects of a common type cannot be updated. (Of course, we can steal the bar for updating :)
2. Why is const introduced?The
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
1. What is const?
A common type is a type described by the Type modifier Const. a variable or object Value of a common type cannot be updated.
. (Of course, we can steal the bar for updating :)
2. Why is const introduced?
The initial purpose
The use of const in C + + is very wide, the meaning of the use of different locations is not the same, so want to write an article to do a summary. First, it is clear that const is the basic meaning of "unchanging", but it does not mean that
1. What is const?
A common type is a type described by the Type modifier Const. The values of variables or objects of a common type cannot be updated. (Of course, we can steal the bar for updating :)
2. Why is const introduced?
The initial purpose
1. What is a const?Const means a constant type, a const-modified variable or object cannot be modified and updated, and of course, in some cases, we can change it rescue.2. Why should I introduce a const?The original purpose was to replace the
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.