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
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.
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.