/函数的分文件编写(以swap为例子)///
1.在头文件创建 .h 文件 ,写函数声明
#include<iostream>
using namespace std;
void swap(int a,int b);
2.在源文件写.cpp文件,输入函数定义
#include "swap.h"
void swap(int a,int b)
{
int temp = a;
a = b;
b = temp;
}
3.在文件中声明后即可直接使用
#include "swap.h"
函数的分文件编写
最新推荐文章于 2022-12-03 12:40:18 发布