0

I want to know why each Cpp developer use ifndef in each file? and what's this functionality and what we will miss if we don't use that?

for example this is one class that I saw lastly:

#ifndef __LexerClassHeader__
#define __LexerClassHeader__

class LexerClass
{
    //some code
}

#endif
RealPeyman
  • 11
  • 4
  • 4
    That’s an [include guard](https://en.wikipedia.org/wiki/Include_guard). However, the particular code you’ve posted is [invalid](https://en.cppreference.com/w/cpp/language/identifiers). – Konrad Rudolph Aug 22 '22 at 17:25
  • 3
    The one you are showing is a bad one by the way. Identifiers containing double underscores are reserved for the compiler and standard library implementation. You are not supposed to define them as macro or declare them in any other way. Use an identifier without double underscore and without underscore at the beginning. – user17732522 Aug 22 '22 at 17:27

0 Answers0