c++ 函数重载示例程序

来源:互联网 发布:贵州师范大学教务网络 编辑:程序博客网 时间:2024/05/22 14:18

 

//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;
}

原创粉丝点击