0

How to Create a header file in c or c++?

Is creating Header files a complex one?

25th Jul 2017, 12:28 PM
Sai Yerni Akhil
Sai Yerni Akhil - avatar
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 }
25th Jul 2017, 1:49 PM
Hatsy Rei
Hatsy Rei - avatar
+ 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
30th Jul 2017, 12:01 PM
Jamie
Jamie - avatar