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

const-5-(2) #284

Closed
Zongshichao opened this issue Apr 12, 2023 · 4 comments
Closed

const-5-(2) #284

Zongshichao opened this issue Apr 12, 2023 · 4 comments

Comments

@Zongshichao
Copy link

const指针必须进行初始化,且const指针的值不能修改。

#include<iostream> using namespace std; int main(){ int num=0; int * const ptr=&num; //const指针必须初始化!且const指针的值不能修改 int * t = &num; *t = 1; cout<<*ptr<<endl; }
这里const指针是可以直接修改值的,只是指向不可以改,不需要通过另外的指针修改吧?

@shraddha761
Copy link

Hye
Assigned me this issue want to work on issue

@laialaodi
Copy link
Contributor

laialaodi commented Apr 17, 2023

@Zongshichao 这里 const指针的值 指的是const指针的指向吧,不过这段话确实容易引起误会

@JKYovo
Copy link

JKYovo commented Apr 17, 2023

确实,应该是const指针的指向不能修改,值是可以修改的,这里可能表达不清楚

@laialaodi
Copy link
Contributor

那我把原文改一改吧

laialaodi added a commit to laialaodi/CPlusPlusThings that referenced this issue Apr 24, 2023
laialaodi added a commit to laialaodi/CPlusPlusThings that referenced this issue Apr 25, 2023
laialaodi added a commit to laialaodi/CPlusPlusThings that referenced this issue Apr 26, 2023
laialaodi added a commit to laialaodi/CPlusPlusThings that referenced this issue Apr 26, 2023
laialaodi added a commit to laialaodi/CPlusPlusThings that referenced this issue Apr 26, 2023
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

4 participants