0

Doubt regarding case sensitivity of #ifndef and #define used in the c++ course

#ifndef MYCLASS_H is used in header file of MyClass(), but C++ a case sensitive language?! How will it interpret this macro to be an instruction to include header?

16th Jun 2017, 11:42 AM
Nitish Yadav
Nitish Yadav - avatar
5 Réponses
+ 3
Yes. The name C.h is the file name. The header name, though, is Cc_H Basically, they prevent including the header more than once. Eg - you call cmath twice. This can make the program slow To prevent this, we use these guards which prevent defining the header more than once...
16th Jun 2017, 12:04 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
Thats the naming by default. You may change it to MyClass_H The truth is that this define has nothing to do with the name. The define is what makes your header readable. Even if you have c.h, You may have a include guard like this in it: #ifndef Cc_h #define Cc_h #endif For the compiler, it is Cc_h But for you, it is c.h...
16th Jun 2017, 11:56 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
Welcome ^_^
16th Jun 2017, 12:06 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
Thank you. Okay so that means that once a header for particular class is included in main function then during execution these lines check if the header was included or should be included now(ifndef) and the name given just acts as an identifier?
16th Jun 2017, 12:01 PM
Nitish Yadav
Nitish Yadav - avatar
+ 1
Thank you!
16th Jun 2017, 12:05 PM
Nitish Yadav
Nitish Yadav - avatar