简体   繁体   English

练习:C ++中的指针和引用

[英]Exercise: pointers and references in C++

Is this correct: 这个对吗:

a) Pointer p1 to a char: a)指针p1到char:

char* p1;

b) A constant pointer p2 to a char: b)一个常量指针p2到char:

char* const p2;

c) pointer p3 to a constant char: c)指针p3到常量char:

const char* p3;

d) A constant pointer p4 to a constant char: d)常量指针p4到常量char:

const char* const p4;

e) A reference r1 to a char: e)对char的引用r1:

char & r1;

f) A reference r2 to a constant char: f)对常量char的引用r2:

const char& r2;

Would you please notify me any mistakes? 你能告诉我任何错误吗?

They are all correct. 他们都是正确的。 I can't see any mistakes :-) 我看不出任何错误:-)

没有错,一切都是正确的。)

Everything looks correct. 一切看起来都很正确。 A rule of thumb to use in C/C++ is to read it right to left. 在C / C ++中使用的经验法则是从右到左阅读。 For example: const char *p is a pointer( * ) to a character that is constant/constant character. 例如:const char * p是指向常量/常量字符的字符的指针(*)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM