Classes declarations usually look like that:
#ifndef MY_CLASS_20141116
#define MY_CLASS_20141116
...
class MyClass
{
...
}
#endif
My question is, why to not use the class name instead of redefining a new identifier:
#ifndef MyClass
...
class MyClass
{
}
#endif
I guess it has something related with identifier conflicts (a same identifier may appear twice) or the use of namespace (I do not know if a full identifier like std::array may be used in the #ifndef directive).
It would be great a more thorough explanation.
Also, it is possible to use the second test when using namespace?
#ifndef A::MyClass //not compile, any equivalent?
namespace A
{
...
class MyClass
{
}
}
#endif