#include "iostream"
using namespace std;
short func(short a,short b)
{
return a+b;
}
int func(int a,int b)
{
return a+b;
}
float func(float a,float b)
{
return a+b;
}
int main()
{
short a=10,b=23;
int m=20,n=34;
float i=1.2,j=9.0;
cout<<func(a,b)<<endl;
cout<<func(m,n)<<endl;
cout<<func(i,j)<<endl;
}
追问如果说两个数是必须是输入的呢?
追答改一下main函数
int main()
{
short a,b;
int m,n;
float i,j;
cin>>a>>b;
cin>>m>>n;
cin>>i>>j;
cout<<func(a,b)<<endl;
cout<<func(m,n)<<endl;
cout<<func(i,j)<<endl;
}