I have a header file called calendarType.h
Is it appropriate to add
#ifndef calendarType
#define calendarType
and
#endif as the last row?
I have a header file called calendarType.h
Is it appropriate to add
#ifndef calendarType
#define calendarType
and
#endif as the last row?
Yes, those will work to make sure the lines in between #ifdef and #endif are only parsed once during each compilation (even if they get #include'd from more than one location)
The only thing I might do differently is to change calendarType to calendarType_h in each of the first two lines -- that will help make sure the #define'd macro-token doesn't interfere with any class or struct named calendarType.
Those are called include guards. They should be used in most header files to avoid a problem known as double inclusion. Double inclusion will most likely result in failed compilation. From Wikipedia:
If certain C or C++ language constructs are defined twice, the resulting translation unit is invalid.
#pragma once is an alternative to traditional include guards. While not actually part of the C++ standard, it is well supported across compilers. #pragma once is less code to type and less prone to error (e.g. accidentally re-using the same include guard).