当前位置:网站首页>6. const usage, combination of first and second level pointers
6. const usage, combination of first and second level pointers
2022-06-23 01:40:00 【For financial freedom!】

C file :
It's all printed out 30,const The amount of modification is called a constant ! Cannot be an array parameter !
C++ file :
C++ in , All appear const Where constant names are , Are replaced by the initialization of constants !( Refer to detai C++ Anatomy column , It involves the concept of constant table !) Design to constants at compile time a Is replaced by a constant !
const Combined with one or two level pointers
sonst The common mistake in the amount of decoration is :
- Constants can no longer be used as lvalues
- The address of a constant cannot be disclosed to an ordinary pointer or ordinary reference variable ( You can modify the value of a constant indirectly !)
C++ language norm :const It's the type closest to him !
first line :*p Cannot be used as an lvalue :*p=20 error ,p=&b Sure (const Modification is int type )
The second line : Same as the first line , Modification is int
The third line : Modification is int * , in other words p Is a constant , Cannot point to other memory !*p Assignable ( Modify the value of the memory pointed to through pointer dereference )
In the fourth row : first const modification int(*p), The second modification int*(p)!
const Sum up the formula :
const If there is no pointer on the right * Words ,const It's a non participating type !
The above is wrong , Will report a mistake !
边栏推荐
- SQL programming task03 job - more complex query
- Centos7 installing postgresql12
- Pat class A - 1014 waiting in line (bank queuing problem | queue+ simulation)
- Wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe
- A hundred lines of code to realize reliable delay queue based on redis
- The longest child sequence of the 2019 Blue Bridge Cup
- [hdu] p7058 ink on paper finding the maximum edge of the minimum spanning tree
- Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
- Knowledge point learning
- three. JS simulated driving tour art exhibition hall - creating super camera controller
猜你喜欢

2D prefix and

Lexical Sign Sequence

Use elk to save syslog, NetFlow logs and audit network interface traffic

Day367: valid complete square

Template specialization template <>

MySQL -- how to access the database of a computer in the same LAN (prenatal education level teaching)

Explain the startup process of opengauss multithreading architecture in detail

Autumn move script a

Overview of visual object detection technology based on deep learning

Detailed explanation of clip attribute parameters
随机推荐
Quick sort method
Day575: divide candy
Up the Strip
Day367: valid complete square
Philosopher's walk gym divide and conquer + fractal
Is it safe for Hongyuan futures to open an account? Can Hongyuan futures company reduce the handling fee?
JS to determine whether the browser has opened the console
Autumn move script a
Autumn move script B
JS to read the picture of the clipboard
On function overloading from several examples
Thread local storage understanding
JS to paste pictures into web pages
使用aggregation API扩展你的kubernetes API
Const defined variables and for of and for in in JS
LeetCode 206. Reverse linked list (iteration + recursion)
Google benchmark user manual and examples
Learn the specific technical learning experience of designing reusable software from the three levels of class, API and framework
Pat class A - 1013 battle over cities
[22 summer reconstruction 1] codeworks round 791 (Div. 2)