Strive for the easiest ways *, &

zhaozj2021-02-08  257

Strive to make the easiest ways *, & it clearly. These two symbols have many confused places. Let me say * 1. Define the pointer. INT i = 6; int * p; definition pointer P = & i; here & is to take the address, hereby

2. Use the value. INT i = 6, j; int * p; definition pointer P = & i; here & is to take the address, here there is J = * P;

3. Multiplication. INT A = 5, B = 6, C; c = a * b; hehe ~ no one will be mixed.

Again & 1. Define the reference. INT i = 6; int & m = i; definition reference

2. Take the address. INT i = 6; int * p; definition pointer P = & i;

3. The bit bit is the same as the above situation, it will not be confused, don't say much. :)

Define pointers, values, definition references, take address, which are confusing, and look at the following example.

Void test () {INT i = 6, j; int & = i; definition reference INT * p1 = null, * p2 = null; define two pointers

P1 = & i; take address P2 = & m; take address (address of reference M) j = * p1; value j = * p2; value M ; j = i; i also increased} single step To more information: i = 6; & i = 0x0086d7d0 m = 6; & m = 0x0086d7d0 m and i's address, so the value inside is absolutely the same. m is a reference (can be said, m is i), the operation of M is the operation of I, and the operation of the same to i is the operation of M. Quote is an alias. m is i, i is M. Again, Zhang San, call her small Zhang in the company, today employees give Xiao Zhang 300RMB, employee B is 500RMB, and now give the three three-small RMB? 800. :) Zhang San is Xiao Zhang, Xiao Zhang is Zhang San.

P1 = 0x00867d0; * p1 = 6; & p1 = 0x0065fdec; p2 ​​= 0x00867d0; * p2 = 6; & p2 = 0x0065FDE8; P1, P2 two pointers, content is 0x00867d0. They point to the same address, so there is * P1 equal to * P2 is 6. But two of them are different, so & P1 and & P2 are different.

The above is only related to C and is only part. And the C class is being organized, and it is also posted later. The first pride is throwing brick. Oh ~

转载请注明原文地址:https://www.9cbs.com/read-3399.html

New Post(0)