已采纳回答 / sina志由飞想
挺佩服你的细心,如果这样写的函数重载,编译器由于 函数的二义性 编译器自己也SB了,不知道选哪个函数重载好,就会出现类似的编译错误 “error C2668: 'add' : ambiguous call to overloaded function”;
2017-03-02
{
int maxNum = arr[0];
for (int i = 1; i < count; i++)
{
if (maxNum<arr[i])
{
maxNum = arr[i];
}
}
return maxNum;
}
int main(void)
{
int numArr[3] = { 3, 8, 6 };
cout << getMax(numArr[2], 100) << endl;
cout << getMax(numArr,3)<< endl;
system("pause");
return 0;
}
int maxNum = arr[0];
for (int i = 1; i < count; i++)
{
if (maxNum<arr[i])
{
maxNum = arr[i];
}
}
return maxNum;
}
int main(void)
{
int numArr[3] = { 3, 8, 6 };
cout << getMax(numArr[2], 100) << endl;
cout << getMax(numArr,3)<< endl;
system("pause");
return 0;
}
最新回答 / 林下夕阳
int *P=new int[1000] //申请一个含1000个元素的整型数组p[0]=10 //给数组的第一个元素赋值为10cout<<p[0]<<endl //打印p[0]的值
2017-02-25