If one actually wants functions placed into the global namespace, then is there any benefit to using this style:
#include <cfoo>
using namespace std;
Or can one just do
#include <foo.h>
for an identical effect?
If one actually wants functions placed into the global namespace, then is there any benefit to using this style:
#include <cfoo>
using namespace std;
Or can one just do
#include <foo.h>
for an identical effect?
If "foo.h" is not "properly prepared" to be compiled with C++, it will not work out at all well in a C++ environment.
The "cfoo" style headers are there to make the contents "suitable" for C++. The fact that the old style headers do work is mainly to maintain compatibility.
Both solutions are quite equally bad in the sense that when you later on discover that you have just got a name-clash, so all calls to foo
needs to be updated to use either bleh::foo
or std::foo
to make sure that you know which one is meant.
But at least if you have using namespace std
, you have something to search for. If you want to find all ".h" files, you'll probably find your own .h file, some "ncurses.h" and similar that are not what you where looking for.
So, in conclusion, neither are good solutions, but
#include <cfoo>;
using namespace std;
is a bit less bad.