Is using using namespace std; not good.
I just read an article in the C++ faq and it said that std:: (cout, string etc.) should be used rather than using namespace std; because it causes some kind of conflicts.
If I understood that correctly, the general reason people don't like usingnamespace std is if you upgrade a namespace at a later date, sometimes you may inadvertently duplicate functions in another namespace leading to errors and a headache when debugging.
Yes, it is bad style because it causes namespace pollution.
It must be avoided especially in headers.
example_header.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#ifndef EXAMPLE_HEADER_H
#define EXAMPLE_HEADER_H
#include <string>
// ...
usingnamespace std;
// bad, because now all files including this header will have a
// using namespace std;
// line in them
// ...
#endif
Writing std:: has the potential benefit of making your code easier to understand
This is because other programmers can recognize immediately what parts of the code are your own, and which are from the C++ library.
1 2 3 4 5 6 7 8 9
// ...
func(a, b); // provided by us
std::swap(a, b); // provided by C++ standard library
MyArray<int> ma(30); // provided by us
std::vector<int> vi(30); // provided by C++ standard library
// ...
Hmm. That's probably why it's Code::Blocks not CodeBlocks.
It's gonna be hard to learn c++ thinking about std::blah because i'm using the pdf of this site and there's no std::, so i won't know where it goes. Will it be std::int, std::while etc. Hmm
Out of all those header files, i only know <iostream>, <string> and <sstream>. So the rest is gibberish for now.
Is there any software that uses all/almost all those header files (i'm thinking a game engine and OS)
Probably not.
Most of the useful programs out there just use other libraries to get some help with portability tho.
But there's no standard C/C++ way to create a window.
There are options like GTK, QuickTime...
Also Networking's not in the C/C++ standard (It was proposed).
C++ standard doesn't even assume a console has a X/Y size.
EDIT: After reading Cubbi under me, I found out I re-interpreted your question as "Is there any software that uses only those header files".
Pointing that out, too lazy to rewrite the reply.
Is there any software that uses all/almost all those header files
Yes, many sufficiently complex applications use them all. Except maybe the C compatibility headers (ciso646, cstdbool, ctgmath, cstdalign, and ccomplex).. For example, in the application I'm working on, #include <ciso646> appears 25 times, but I am willing to bet nothing would break if I were to remove it - all our compilers are decent enough to not need it.
i'm thinking a game engine and OS
I'm not familiar with game engines, but most existing OSes are written in C, so they don't really use the C++ library.