Creating a header file

Oct 17, 2010 at 4:23pm
Does anyone know where their is a simple example of how a header file is created? My textbook explains what it is, and when to use it, but I don't understand if it is a different file I save somewhere in my Dev-cpp directory or somewhere else.
Oct 17, 2010 at 4:30pm
Probably file->new->file and there select 'header' somewhere. Just guessing. Actually, you could open explorer, right click -> new -> text document, write the header code in the text file, and add #include "relative_or_global_path_to_the_file_and_file_name" to your code and it would work.
Oct 17, 2010 at 4:38pm
Thanks! I'll give that a try.
Oct 18, 2010 at 1:06am
Usually when you start a new project you can select a project type. But you need to include the header file in the same root folder with the rest of the project. And like hamsterman previously explained “write the header code in the text file, and add #include "relative_or_global_path_to_the_file_and_file_name" to your code and it would work.”

Like in the example below in lines 4 and then 6.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <fstream>
#include <string>

#include "person.h"

class employee: public person
{
      public:
             employee(void);
             employee(const char *outputPath);
             
             ~employee(void);
             
      private:
              
              std::string theOutputPath;
      };


UAT-Student
Topic archived. No new replies allowed.