Re: Differences between <headerfile.h> and "headerfile"
Christian wrote:
I've found a program that has #include <fstream.h> as include
directive. Visual Studio can't find it,but if I write #include
"fstream" it can find it. I cannot understand how Visual Studio
operate in this case and its notations. Someone could explain it to
me?
Several things here:
1. The C++ standard defines a bunch of headers (e.g. 'fstream'
and 'iostream'). Those are included with #include <fstream>. Everything
else, like e.g. windows.h is not a C++ header. Note also that C++ doesn't
require these headers to actually be implemented as files, it could be some
compiler-internal data structure activated there.
2. In order to include a file in another file, C++ says you should use
#include "otherfile", e.g. #include "my class.h".
3. The distinction that C++ makes about headers is traditionally blurred.
That means that 'system' header files are also usually included with angled
brackets like #include <windows.h>. This is incorrect as far as C++ is
concerned but established practice.
4. For your own header files (i.e. those that are part of the project in
question), you should use the "" syntax and make the filenames end
with '.h' or '.hpp'.
5. 'fstream.h' is not a part of C++. This is a header of the old,
pre-standard IOStreams library. The IOStreams in the C++ standard are
templates and they all live in namespace std, so the contents
of 'fstream.h' and 'fstream' are not the same though they are similar. Do
not use fstream.h and be cautious of code that does!
Uli