C++函数重载的使用
来源:优易学  2011-12-15 17:55:50   【优易学:中国教育考试门户网】   资料下载   IT书店

  //函数重载的使用

  #include<iostream>

  using namespace std;

  int max(int,int);

  int max(int,int,int);// 函数如果定义在后应该先声明在调用

  void main()

  {

  cout<<max(25,35)<<","<<max(25,39,35)<<endl;

  }

  int max(int m1,int m2)

  {  return(m1>m2)?m1:m2;}//三目运算

  int max(int m1,int m2,int m3)

  {

  int t=max(m1,m2);

  return max(t,m3);

  }

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训