Yesterday I wrote in error #include "iostream"
and I did not realize because the compiler did not give an error. Later I realized and I was surprised.
I've tried with this little program:
// Fichero a.h
#ifndef A_H
#define A_H
#endif // A_H
// Fichero a.cpp
#include <iostream>
#include "a.h"
int main(void) {
std::cout << "Hola Mundo" << std::endl;
return 0;
}
Which works as expected.
It also works if I put the two includes with double quotes " "
, this has surprised me.
If I put them the two includes with less major < >
I get a compilation error, which is what I expect:
a.cpp: 2: 15: fatal error: a.h: No such file or directory
I thought that:
-
#include < >
is for system headers or libraries. -
#include " "
is for programmer headers.
But it's clear that not because iostream can also be included with " "
.
Can I just include everything with " "
?
Or could it have any adverse effect doing it all with " "
? And if so, what criteria to use to decide each include if done with " "
or < >
?