key point: Const is a modifier, and the key is to see where the Const modifier is.1, const int *Ahere the const modifier is int, and int defines an integer valueTherefore, the object value pointed to by *a cannot be modified by *a, but can be
A const reference is a reference to a const object.
Copy codeThe Code is as follows: const int I = 10;
Const int & ref = I;
You can read the ref but cannot modify it. This makes sense, because I itself cannot be modified, and of course it cannot
the top-level const is a constant (immutable) that represents the object itself;The underlying const is a constant (pointed immutable) that represents the object to which it is pointing;1#include 2 3 intMain ()4 {5 intI=0;6 int*Constp1=&i;//-
A const reference is a reference to a const object.
Copy Code code as follows:
const int i = 10;
const int &ref = i;
Ref can be read, but cannot be modified. It makes sense to do so because I cannot modify it, and of course
What does it mean after the const drop function:The const modifier is placed after the function, which is exactly the object that the this pointer is pointing to.For example:Class Student{PublicGetName (int);Privateint stu_id;};The GetName ()
Const & pointer
In the type declaration, const is used to modify a constant. There are two ways to write it. So, what are the following statements that use const to limit immutable content?
1) const is in front
Const int nvalue; // nvalue is
Which definitions are the same for several statements? What are the different definitions? What data can be modified? What data is not modifiable?1 Const int A; 2 int Const A; 3 Const int *A; 4 INT *const A; 5 int Const *const A;In C + +, const is
Const is a C-language keyword that restricts a variable from being allowed to change. The use of const to some extent can improve the security and reliability of the program, in addition, when watching other people's code, clearly understand
The const keyword exists in both C and C ++ languages. Many people have a wrong idea about this keyword. In C, the const keyword is used to make the variable as a constant, variable normalization is like macro definition. In C, the keyword
Reproduced to: http://www.cppblog.com/Marcky/archive/2009/07/12/89796.html
C ++ primer mentions that "only when the form parameter is a reference or pointer, whether the form parameter is const affects the carrying capacity ."Int add (int A, int B )
Read it backwards ...
int*-Pointer to int
int const *-Pointer to const INT
int * const-Const pointer to int
int const * const-const pointer to const INT
Now the first const can is on either
My main blog: half an acre of Square pondThe main references of this paper come from: C + + Primer Chinese version (5th edition) 57th to 58th side1. Top-level const and underlying const conceptAs we know, the pointer itself is an object, because the
Global Variables:
Class, outside of the method, the class directly write NSString * str = @ "xxx"; STR is a global variable (object oriented, to use global variables, generally set as properties of the Class)
Local Variables:
Variables written
C ++ Primer study note _ 24 _ class and data abstraction (10) -- static and Singleton modes, auto_ptr and Singleton modes, const member functions, const objects, mutable modifiers, constmutable
C ++ Primer study note _ 24 _ class and data
Reprint Please specify the source http://blog.csdn.net/xingjiarong/article/details/47282255Keyword const is used to define constants, if a variable is modified by const, then its value can no longer be changed, I think someone must have this
1. Const BasicsIf 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 = & B; [2]Int * const A = & B; [3]Const int * const A = & B;
Http://www.job168.com/info/read_79075.htmlPosting date: a 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 =
I. Const BasicsIf 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 = & B; [2]Int * const A = & B; [3]Const int * const A = &
Recently in re-see >, the first time, the const and constexpr did not understand very well, this time there are some newer understanding, of course, there may still be many wrong places ...First, the const qualifier is "constant", and once a const
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.