+ 17
How to create user-defined header files?
6 Antworten
+ 11
What is a namespace?
and can we use the same method in C language too??
+ 9
inside your header file you can have several sections and you have to name these sections even if there is only one section. Each section in header file is called a namespace.
I don't know about C.
+ 8
In C++, you can follow these steps to create a header file:
step1: create a new file like myheader.h
step2: include necessary header files
step3: create a namespace as follows
namespace mynamespace{
codes for your free functions ...
}
step4: add some functions inside your namespace.
step5: add more namespaces if you need.
now you can include this header file in your program and use its functions.
+ 6
Thanks Dorra
+ 5
In the C language you can create a header file with extension (.h) in which you put all your functions and then in the main file with extension (.c) you put the name of the header file between " " and not between < > as the standard header files.
example: #include <stdio.h> // standard header file
#include "function.h"// user-defined header file
ps : namespace in c++ language is the same stdio.h in c language and it's the header file which contains the input and output standard functions.
+ 2
I believe only C derived languages support header files.
You can read up in C languages with this app. But simply put, header files just contain prototypes functions for the related class and helps for compiling.
Hence, just define your own class.