Besides cout, cin, and endl, what exactly does using namespace std; include?
Besides cout, cin, and endl, what exactly does using namespace std; include?
It's a way of compartmentalising declared variables and type definitions.
When you link to multiple libraries, people are bound to re-use names. Namespaces help to avoid this.
What would you call a dictionary class type? Dictionary perhaps, or may Dict? If you had to link to two libraries where the same name was used twice it would cause a problem. However, with namespaces you can refer to them as, for example:
Acme:ict
and
SuperSoft:ict
You explained what it does, but what does it include?
It includes a lot, a lot to list.
but other examples.
ifstream
ofstream
vector
string
iomanip stuff
etc. etc.
Ooops! So I did. Must take time to read questions more thoroughly.
Try this:
http://www.cs.rpi.edu/projects/STL/htdocs/stl.html
What does the standard template library have to do with this?
Anyway, for example: if you only use cout, cin and endl in your program, you can use this...
using std::cout;
using std::cin;
using std::endl;
...instead of using namespace std;
I just want to know what all of the - how should I say this? - std's.
I know a few more...
using std::ios;
using std::fixed;
using std::showpoint;
Every standard header file that doesn't end in .h is found in the std namespace. However, to have access to the specific part, you have to include the correct header.
>>Every standard header file that doesn't end in .h is found in the std namespace. However, to have access to the specific part, you have to include the correct header.
I'm sure there are too many header files for you to list here, so can you provide a link or anything to where I may find a listing of all of them? Please
It's been a while since I've been out here, volk, but a reasonably good response to your question can be found in Scott Meyers' book, Effective C++.
Unless you're writing a paper, or something of the sort, a good compiler will be happy to tell you when you've "messed up", i.e. included a command not included in namespace std.
That being said, there are a myriad of threads available suggesting against the use of "using namespace std".
You've cited examples of avoiding such use, yourself. From a "maintenance" standpoint...hmmmm. Might be some "backtracking" involved.
-Skipper
"When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow
using std::cout;
using std::cin;
using std::endl;
...instead of using namespace std;
Yes, you can do that. I know some people advocate doing it the first way, but why would anyone want to do all that typing? The second method only requires you to type one line.
it's a preference of style. some people prefer not to pollute the global space.Originally posted by 7stud
using std::cout;
using std::cin;
using std::endl;
...instead of using namespace std;
Yes, you can do that. I know some people advocate doing it the first way, but why would anyone want to do all that typing? The second method only requires you to type one line.
Basically, when you say using namespace std;, if anything has a variable name that you are using, the compiler chokes because of multiple declarations.
As for a list, www.dinkumware.com