指针所占内存空间
int main() {
int a = 10;
int* p;
p = &a; //指针指向数据a的地址
cout << *p << endl; //* 解引用
cout << sizeof(p) << endl;
cout << sizeof(char*) << endl;
cout << sizeof(float*) << endl;
cout << sizeof(double*) << endl;
return 0;
}
总结:所有指针类型在32位操作系统下是4个字节
C++中的空指针VS野指针
const修饰指针
C语言中指针是const VS 所指是const