0
Use of #ifndef
5 Respostas
+ 1
Please clarify your question. Share code if it concerns a code, and mention language in Relevant Tags to narrow down scoping.
`#ifndef`is preprocessor directive, it is more about deciding which portion of the source code to be processed rather than OOP related (classes - mentioned in Tags).
http://www.cplusplus.com/doc/tutorial/preprocessor/
+ 1
Use of #ifndef here is to prevent MYCLASS_H from being defined more than once.
#ifndef MYCLASS_H // if MYCLASS_H is not defined
#define MYCLASS_H // now define it
// Class definition codes ...
#endif // for #ifndef MYCLASS_H
The lines between #ifndef and #endif is only compiled when MYCLASS_H is not defined yet, once it is defined the #ifndef will give false, thus the lines between will not be processed again.
Hth, cmiiw
0
#ifndef MYCLASS_H
#define MYCLASS_H
class MyClass
{
public:
MyClass();
protected:
private:
};
#endif // MYCLASS_H
0
Okay, but I still don't get what the question is. And you haven't revised your original question to add clarity.
0
Is using #ifndef important can't using just #define enough