简体   繁体   English

如何在dev c ++中创建头文件

[英]how to create a header file in dev c++

I am creating header file for the fist time in dev c++ I have created add.h and add.cpp according to proper format. 我首先在dev c ++中创建头文件,然后根据正确的格式创建了add.h和add.cpp。 I don't know where to store them and when I am using header, it is showing many errors 我不知道将它们存储在哪里,当我使用标题时,它显示了很多错误

Typically my headers look like this: 通常,我的标题如下所示:

#ifndef ADD_H
#define ADD_H

class Add
{
    ...
};
#endif

and I save them in the same directory as my .cpp files. 然后将它们与.cpp文件保存在同一目录中。

In the implementation file: 在执行文件中:

#include "add.h"

And then in the main cpp file: 然后在主cpp文件中:

#include "add.h"

Doesn't matter where you save them, just put them in the same directory. 不管将它们保存在哪里,只要将它们放在同一目录中即可。

You include the header in your .cpp file like this: 您可以在.cpp文件中包含标头,如下所示:

#include "add.h"

Try googling for some beginner C++ tutorials. 尝试谷歌搜索一些初学者C ++教程。

The problem that it is showing many errors is that you may have written incorrect code. 它显示许多错误的问题是您可能编写了错误的代码。 You can start a new question, paste the part of code which you think is cause of the error, with a little description about your code and we'll happily help you out :) 您可以提出一个新问题,粘贴您认为是导致错误的代码部分,并附上一些有关您的代码的描述,我们会很乐意为您提供帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM