using namespace std;
void f(int(&p)[3]){
cout<<p[0]<<endl;
cout<<p[2]<<endl;
}
int main(){
int a1[3]={1,2,3};
cout<<a1<<endl;
cout<<&a1<<endl;
f(a1);
}
编译后输出:
0xbfbb8eb4
0xbfbb8eb4
1
3
#include<iostream>
using namespace std;
void f(int(*p)[3]){
cout<<p[0]<<endl;
cout<<p[2]<<endl;
}
int main(){
int a1[3]={1,2,3};
cout<<a1<<endl;
cout<<&a1<<endl;
f(&a1);
}
编译后输出:
0xbff21e84
0xbff21e84
0xbff21e84
0xbff21e9c
由此比較能够看出,
void f(int(*p)[3]){}是个函数指针数组,指针数组属于二级指针