首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

C++中的const在多维指针中的施用

2013-02-15 
C++中的const在多维指针中的应用void func1(){const int** pp//两个**后,禁止赋值ppnew const int*[1]p

C++中的const在多维指针中的应用

void func1(){const int** pp;//两个**后,禁止赋值pp=new const int*[1];pp[0]=new int[1];//pp[0][0]=0;//error: assignment of read-only location}void func2(){int const ** pp;//两个**后,禁止赋值pp=new const int*[1];pp[0]=new int[1];//pp[0][0]=0;//error: assignment of read-only location}void func3(){int *const * pp;//两个*后,禁止赋值pp=(int *const*)(new int *[1]);//pp[0]=new int[1];//error: assignment of read-only locationpp[0][0]=0;}int main(){return 0;}


热点排行
Bad Request.