想一想?
#include <iostream>
using namespace std;
void testFun(int *po,int len)
{
int size=sizeof(po);
cout<<"InFun:"<<size<<endl;
}
int main()
{
int p[6]={1,2,3,4,5,6};
int sizeP1=sizeof(p);
cout<<"OutFun:"<<sizeP1<<endl;
testFun(p,6);
return 0;
using namespace std;
void testFun(int *po,int len)
{
int size=sizeof(po);
cout<<"InFun:"<<size<<endl;
}
int main()
{
int p[6]={1,2,3,4,5,6};
int sizeP1=sizeof(p);
cout<<"OutFun:"<<sizeP1<<endl;
testFun(p,6);
return 0;
}
输出结果是什么?为什么?
结果:
OutFun:24
InFun:4
原因参见<< C专家编程>>P207