0

Can someone please explain as to the exact function of the #ifndef MYCLASS_H?

The explanation says that #ifndef and #define define the header file if they're not already defined. I do not understand why would you need to define a "file"? It is not a variable, that it needs a definition right? I do not understand the explanation

4th Jan 2017, 5:18 AM
Anmol Shukla
Anmol Shukla - avatar
2 Answers
+ 1
The #include line in the cpp file will copy the content of the header file in the cpp file. In case the header file was included twice, the '#ifndef ... #endif lines are needed so that the actual class declaration is not included twice.
4th Jan 2017, 7:29 AM
ifl
ifl - avatar
0
the lines starting with # are interpreted by the preprocessor, not the compiler. This will generate C/C++ code that can be compiled #ifndef variable means 'if variable is not defined' in preprocessor language.
4th Jan 2017, 6:42 AM
ifl
ifl - avatar