1>为什么不能通过返回值不同来重载函数?
2>利用重载函数的方法来设计一个程序,该程序通过函数“calc()”进行计算并返回结果。
/*
*
*/
#include<iostream>
using namespace std;
int calc(int Squ)
{
return Squ*Squ;
}
int calc(int a,int b)
{
return a*b;
}
int calc(int a,int b,int c)
{
return a + b + c;
}
int main()
{
int d = calc(1);
int e = calc(1, 2);
int f = calc(1, 2, 3);
cout << d << endl;
cout << e << endl;
cout << f << endl;
system("pause");
return 0;
}