打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
C++源码:重载的应用实例

//   C++源码:Example for "OVERLOAD"  重载的应用实例

#include <iostream>
using namespace std;

int   max(int a,int b);
float max(float a,float b);

int max(int a,int b)
 {
   cout<<" \n Now in int max(int a,int b)";
   if (a>b)
     return a ;
     else
     return b;
 }

float max(float a,float b)
 {
  cout<<"\n Now in  float max(float a,float b)\n !";
  if (a>b)
     return a;
     else
     return b;
 }

main()
{
  int x=1,y=1;
  float xx=1.0,yy=1.0;
  {
    cout<<"\007"<<"Please input the INT vallue of X and Y:"<<flush;
    cin>>x>>y;
    cout<<"\nX="<<x<<"\nY="<<y;
    cout<<"\n\n Now,after  max()="<<max(x,y);

    cout<<"\007"<<"\nPlease input the FLOAT vallue \n of XX and YY:"<<flush;
    cin>>xx>>yy;
    cout<<"\n\n Now,after  max()="<<max(xx,yy);
  }
}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
对Point类重载++和――运算符
模板
C++ Template1 SFINEA in C++
拉格朗日(Lagrange)插值法(C语言)
大智慧选股逃顶指标公式源码编程思路破译
C++ limits头文件的用法(numeric
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服