current position:Home>What is the use of inter address access pointer access reference access

What is the use of inter address access pointer access reference access

2022-02-04 16:41:17 CSDN Q & A

As the title
It feels like all this is so troublesome , Why not use a name to access , Is there anything special about these kinds ?




Take the answer :

The memory of the variable is accessed through the pointer , You can change external variables inside the function
If passed directly by value , What is passed is a copy of the value , In other words, the modification of this variable inside the function will not affect the external function



Other answers 2:

A pointer to access The operation is the memory pointed by the pointer
Quote access A reference is an alias for a variable , The operation is the variable itself
(1) Differences in writing
int a = 3;
int *p = &a; //p Is a pointer ,p Point to a The address of
int &b = a; //b yes a References to
(2) Copy differences
When the pointer is assigned or used as a parameter , A shallow copy will occur . References are not copied .

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/02/202202041641156668.html

Random recommended