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 <iostream>2 3 intMain ()4 {5 intI=0;6 int*Constp1=&i;//-----Cannot change the value of P1, which is a top-level const7 Const intB=i;//-----Cannot change the value of B, which is a top-level const (const is the top-level const before the general variable)8 Const int* p2=&b;//-----Can change the value of the P2, which is an underlying const (the object is a const, so you can point to the top layer)9 Const int*ConstP3=P2;//-On the right is the top-level const, on the left to the bottom of the thing const;Ten Const int& Some=i;//---Used to declare references, are the underlying const; One}
When the copy operation of the object is performed, the difference between the top-level const or the underlying const is obvious, and the top-level const is not affected;
The underlying const execution copy is a type of 2 object that must be the same, or convertible, and the general amount can be converted to constants;
C + + top-level const and underlying const