#include <iostream>
#include <typeinfo>
using namespace std;
int main() {
int*(*pp())[3];
int**(*PPP)[3];
double (*FuncPtr)(float);
void(Func)(int, float);
cout << typeid(pp).name() << endl;
cout << typeid(PPP).name() << endl;
cout << typeid(FuncPtr).name() << endl;
cout << typeid(Func).name() << endl;
return 0;
}
输出:

总结:
- P代表指针,而P*代表某种指针;
- F代表函数,PF代表函数指针,函数类型以E结尾,中间的内容分别是:函数的返回值类型,函数的参数类型;
- A代表数组,紧接着的数字是数组长度,再后面的下划线内容是(_×××)元素类型;
代码例子说明:
int**(*PPP)[3]:ppp是一个数组指针,数组的长度是3,元素的类型是int**;int*(*pp())[3]:pp是一个函数,函数的返回值是一个数组指针,函数的参数是空(void),这个数组的长度是3,元素类型是int*;double (*FuncPtr)(float):FuncPtr是一个函数指针,函数的返回值是double,函数有一个float参数;void(Func)(int, float):func是一个函数,函数的返回值是空(void),函数有两个参数:int、float;

本文详细解析了C++中的指针和函数指针的使用,包括数组指针、函数指针的声明与类型。通过实例展示了如何声明和使用函数指针,以及数组指针的类型表示。讲解了`pp`、`PPP`、`FuncPtr`和`Func`四个类型的含义,帮助理解C++中复杂的指针和函数指针操作。
49






