Exercise: pointers and links in C ++

Is it correct:

a) Pointer p1 to a char:

char* p1; 

b) Permanent pointer p2 to a char:

 char* const p2; 

c) pointer p3 to char constant:

 const char* p3; 

d) Permanent pointer p4 to char constant:

 const char* const p4; 

e) Link r1 to a char:

 char & r1; 

f) Link r2 to char constant:

 const char& r2; 

Could you notify me of any errors?

+6
source share
3 answers

They are all correct. I see no errors :-)

+4
source

No mistakes, everything is correct.)

+3
source

Everything looks right. The rule of thumb used in C / C ++ is to read it from right to left. For example: const char * p is a pointer (*) to a character that is a constant / constant character.

+2
source

Source: https://habr.com/ru/post/891395/


All Articles