如何为 c++ 多文件程序制作一个方便的结构?

问题描述 投票:0回答:0

我将程序分成几个部分并创建了头文件。我将所有标题分别放在一个文件夹中,而程序本身则放在另一个文件夹中。我可以这样做吗?

我试着这样做: photo of the structure of files

在头文件 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"

但是当我尝试运行程序时,它找不到合适的功能。 Photo of the error

c++ header
© www.soinside.com 2019 - 2024. All rights reserved.