简体   繁体   中英

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. 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.

In the implementation file:

#include "add.h"

And then in the main cpp file:

#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:

#include "add.h"

Try googling for some beginner C++ tutorials.

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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