#include<iostream>;usingnamespace std;//函数的声明:定义只能又一次,声明可以多次intmain(){//函数声明intmax(int a,int b);int a =100;int b =50;int c =max(a,b);
cout <<"c="<< c << endl;system("pause");return0;}intmax(int a,int b){int max;if(a > b){
max = a;}else{
max = b;}return max;}
04函数的分文件编写
主函数源文件
#include<iostream>;usingnamespace std;//引入头文件#include"swap.h";//函数的分文件编写//1.创建后缀名为.h的文件:swap.h//2.创建后缀名为.cpp的源文件:swap.cpp//3.在头文件中写函数的声明//4.在源文件中写函数的定义//函数的分文件编写//实现两个数字进行交换的函数intmain(){int a =100;int b =50;swap(a,b);system("pause");return0;}