Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

练习 2.27答案存在问题 #94

Open
zhangnuc opened this issue Dec 28, 2022 · 0 comments
Open

练习 2.27答案存在问题 #94

zhangnuc opened this issue Dec 28, 2022 · 0 comments

Comments

@zhangnuc
Copy link

(b) int *const p2 = &i2; 应该是不合法的。
我自己代码尝试了一下,会返回报错“error: cannot initialize a variable of type 'int *const' with an rvalue of type 'const int * “

我理解的原因是由于i2是一个常量,而常亮的地址只能被存放在 指向常量的指针中。p2是一个常量指针,而非 指向常量的指针。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant