一、源代码的组织
头文件(*.h):#include头文件、函数的声明、结构体的声明、类的声明、模板的声明、内联函数、#define和const定义的常量等。
源文件(*.cpp):函数的定义、类的定义、模板具体化的定义。
主程序(main函数所在的程序):主程序负责实现框架的核心流程,把需要用到的头文件用#include包含进来。
按图片中顺序,文件内容如下:
#include "tools.h"
#include "girls.h"
void test()
{
cout << "max(4,6)=" << max(4, 6) << endl;
cout << "min(4,6)=" << min(4, 6) << endl;
}
int main()
{
test();
return 0;
}
#include "girls.h"
void print(int no, string str)
{
cout << no << " " << str << endl;
}
#pragma once
#include <iostream>
#include "tools.h"
using namespace std;
void print(int no, string str);
#include "too