我将程序分成几个部分并创建了头文件。我将所有标题分别放在一个文件夹中,而程序本身则放在另一个文件夹中。我可以这样做吗?
在头文件 genFunctions.h
#ifndef __GENFUNCTIONS_H__
#define __GENFUNCTIONS_H__
#include <iostream>
using namespace std;
void showError();
void pause();
void clearConcole();
#endif
在程序文件genFunctions.cpp中:
#include "../headers/genFunctions.h"
void clearConcole(){
// ...
}
void pause(){
// ...
}
void showError(){
// ...
}
在main.cpp中:
#include "headers/genFunctions.h"