update dir

This commit is contained in:
light-city
2019-07-14 16:52:20 +08:00
commit 57627e0b75
30 changed files with 714 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,9 @@
#include<iostream>
using namespace std;
int main(){
const int p = 10;
const void *vp = &p;
void *vp = &p; //error
}

View File

@@ -0,0 +1,12 @@
#include<iostream>
using namespace std;
int main(){
const int *ptr;
int val = 3;
ptr = &val; //ok
int *ptr1 = &val;
*ptr1=4;
cout<<*ptr<<endl;
}

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;
}

Binary file not shown.

View File

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