CPlusPlusThings
CPlusPlusThings copied to clipboard
const-5-(2)
const指针必须进行初始化,且const指针的值不能修改。
#include<iostream> using namespace std; int main(){ int num=0; int * const ptr=# //const指针必须初始化!且const指针的值不能修改 int * t = # *t = 1; cout<<*ptr<<endl; }
这里const指针是可以直接修改值的,只是指向不可以改,不需要通过另外的指针修改吧?
Hye Assigned me this issue want to work on issue
@Zongshichao 这里 const指针的值
指的是const指针的指向吧,不过这段话确实容易引起误会
确实,应该是const指针的指向不能修改,值是可以修改的,这里可能表达不清楚
那我把原文改一改吧