0
How to Create a header file in c or c++?
Is creating Header files a complex one?
2 odpowiedzi
+ 10
Your header file can contain class method definitions. It's just tidier to put them in seperate files.
Just back OT:
A header file is different from your source file in the sense of :
• file extension - .h instead of .cpp
• file contents - May contain namespaces, class declarations and definitions.
E.g.
header.h
class headerclass
{
public: //codes
private: //codes
};
main.cpp
#include <iostream>
#include "header.h"
int main()
{
headerclass obj;
// codes
}
+ 2
Also, don't forget headers are used a lot with the preprocessor to set things up, eg:
#ifdef ___my_embed_os
BUFF_MAX = 128;
#endif