Aj Godinez Aj Godinez - 1 month ago 11
C++ Question

What is the difference between #include "MyClass.h" and #include ".\myclass.h"

I'm developing in VS2010 and looking to add code to an already existing project.
This is a Win32/MFC by the way.

And I couldn't help but notice that in class MyClass (in this case MyClass was an extension of the CDialog Class) the following was included at the top of the cpp file:

#include "MyClass.h"
#include ".\myclass.h"

I noticed that the second include was typed in without capitalization, but I couldn't quite figure out why?

Answer Source

"MyClass.h" will be searched on INCLUDE_DIR path, which is defined in your project settings.

" ./myclass.h" will be searched in the same directory than the current file.

Windows files names are not case-sensitive so if your working dir is in your include path, these lines are pointing to the same file.

This redundancy is probably a way for VS to ensure the file will be included at least once...