c++ 函数的函数声明

c++ 函数的函数声明

 

只要在被调用函数的首部的末尾加一个分号,就成为对该函数的函数声明。函数声明的位置应当在函数调用之前。

#include <iostream>
using namespace std;
int main( )
{ int max(int x,int y);         //对max函数作声明
  int a,b,c;
  cin>>a>>b;
  c=max(a,b);                   //调用max函数
  cout<<″max=″<<c<<endl;
  return 0;
}
int max(int x,int y)            //定义max函数
{ int z;
  if(x>y) z=x;
  else z=y;
  return(z);
}

 

 

 

 

 

 

 

 

 

posted @ 2014-07-13 14:04  mjorcen  阅读(897)  评论(0编辑  收藏  举报