Teddy said:
If I use just a STL container such as std::vector in my program.
Is "using std::vector;" better than "using namespace std" ?
That's a matter of opinion and it depends on the circumstances. There
appears to be many people who avoid 'using namespace std;', and recommend to
others to avoid it, because it unnecessarily makes all names in the std
namespace visible at global scope, which can lead to inadvertent name
clashes. In practice, I suspect that this hardly ever happens, and if it
does you will almost certainly get a compiler error and easily fix the
problem. I've used it frequently for years and I've never had a problem,
even in large, complex files. I just don't see the point of creating a long
list of specific 'using's that you have to keep adding to every time you use
a new name when a single line takes care of it. The only thing I would
suggest is avoiding putting any 'using' at global scope in a header file,
because then individual source files that include the header lose control of
them.
Does "using namespace std" cost ?
In what sense 'cost'? The difference between them is the name lookup during
compilation.
DW