C++函数的声明和定义

2020-01-06 12:14:53于丽

int min(int a,int b,int c)
{
   if (a<=b && a<=c) return a;
   if (b<=a && b<=c) return b;
   return c;
}
void output(int a)
{
   cout <<a <<endl;
   return;//返回空类型
}
运行结果:
4
2
要注意,一旦函数运行结束,那么该函数中声明的参数和变量都将消失。就像下课了,同学们都回家了,老师叫谁都是叫不应的。