现在的位置: 首页 > 综合 > 正文

c++ 函数重载示例程序

2012年08月05日 ⁄ 综合 ⁄ 共 460字 ⁄ 字号 评论关闭

 

//author:p_x_l

//copyright: 版权所有,翻版不究

 

 

#include <iostream>
#include <string>

using namespace std;

void test(int a);
void test(long a);
void test(float a);
void test(double a);

int main()
{
 test(2); 
 test(2332); 
 test(1.32554); 
 test(234.342); 

 while(1);
}

void test(int a)
{
 cout<<"int 平方"<<endl;
 cout<<a*a<<endl;
}
void test(long a)
{
 cout<<"long 平方"<<endl;
 cout<<a*a<<endl;

}
void test(float a)
{
 cout<<"float 平方"<<endl;
 cout<<a*a<<endl;

}
void test(double a)
{
 cout<<"double 平方"<<endl;
 cout<<a*a<<endl;
}

抱歉!评论已关闭.