呵呵早上看见坛子里有要面试题的,我写了一个以前自己以前范过错误的问题,呵呵贴出来
void new_int_arr(int** pNewInt)
{
pNewInt = new int*[50];
for(int i = 0;i<50;i++)
pNewInt[i] = new int[50];
}
int** new_int_arr()
{
int** pNewInt = new int*[50];
for(int i = 0;i<50;i++)
pNewInt[i] = new int[50];
return pNewInt;
}
void new_int_arr(int**& pNewInt)
{
pNewInt = new int*[50];
for(int i = 0;i<50;i++)
pNewInt[i] = new int[50];
}
分析异同,其中有一个是错的 ,编译都能通过哦
这是考c指针的和函数传参规则,基本上写代码多了的人都能分析出来