写一个重载函数,实现2个数的乘法

如题所述

第1个回答  2010-10-05
#include <cstdlib>
#include <iostream>

using namespace std;

long multiply(int a,int b);
double multiply(double a,double b);

int main(int argc, char *argv[])
{
int i=3,j=4;
double h=2,t=6;
long l=multiply(i,j);
double d=multiply(h,t);
system("PAUSE");
return EXIT_SUCCESS;
}

long multiply(int a,int b)
{
cout<<"Using the int multiply"<<endl;
return a*b;
}
double multiply(double a,double b)
{
cout<<"Using the double multiply"<<endl;
return a*b;
}本回答被网友采纳
第2个回答  2010-10-05
function CF(N1,N2:string):string;overload;
begin
result:=IntToStr(strtoint(N1)*strtoint(N2));
end;

function CF(N1,N2:integer):integer;overload;
begin
result:=N1*N2;
end;

{这个是用delphi写的,所谓重载就是两个函数名相同,参数的个数或参数类型不同}