This commit is contained in:
Light-City
2019-11-05 16:56:07 +08:00
parent 3a495d7fa2
commit 8edbbbc5a2
179 changed files with 428 additions and 26 deletions

Binary file not shown.

View File

@@ -0,0 +1,10 @@
#include<iostream>
using namespace std;
int main(){
int num=0;
int * const ptr=&num; //const指针必须初始化且const指针的值不能修改
int * t = &num;
*t = 1;
cout<<*ptr<<endl;
}

View File

@@ -0,0 +1,8 @@
#include<iostream>
using namespace std;
int main(){
const int num=0;
int * const ptr=&num; //error! const int* -> int*
cout<<*ptr<<endl;
}

Binary file not shown.

View File

@@ -0,0 +1,8 @@
#include<iostream>
using namespace std;
int main(){
const int num=10;
const int * const ptr=&num; //error! const int* -> int*
cout<<*ptr<<endl;
}