470,849 Members | 1,137 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

What is std:: ?

Hi all,

Ok, my class book doesn't cover this yet I see it being used with very
basic statements such as cout. It is also covered in other C++ books in
the first program (I was skimming at Borders) so what does it actually
do? And you can imagine the results I get when putting std into google.

Thanks,

Matt
May 14 '06 #1
5 1932
* ComicCaper:
Hi all,

Ok, my class book doesn't cover this yet I see it being used with very
basic statements such as cout. It is also covered in other C++ books in
the first program (I was skimming at Borders) so what does it actually
do? And you can imagine the results I get when putting std into google.


"std::whatever" refers to a name "whatever" from the standard library.

Technically it states which namespace (namely, "std") the name is
defined in, or at least is available in.

That helps to avoid name collisions: you can have the same name, with
different meanings, in different namespaces.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
May 14 '06 #2
ComicCaper wrote:
Ok, my class book doesn't cover this yet I see it being used with very
basic statements such as cout. It is also covered in other C++ books in
the first program (I was skimming at Borders) so what does it actually do?
And you can imagine the results I get when putting std into google.


All the Standard Library identifiers are in a namespace called std. Googling
"namespace std" with quotes gives this first good hit:

http://www.cplusplus.com/doc/tutorial/namespaces.html

You need to suspect your class and tutorial if it doesn't cover these
things. They have been the de-facto standard for >10 years now.

Whether you suspect your class or not, always learn anything - especially
C++ - from many more sources than an assigned textbook.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
May 14 '06 #3
ComicCaper wrote:
Hi all,

Ok, my class book doesn't cover this yet I see it being used with very
basic statements such as cout. It is also covered in other C++ books in
the first program (I was skimming at Borders) so what does it actually
do? And you can imagine the results I get when putting std into google.

Thanks,

Matt


As to the googling part: you can easily get useful descriptions by
searching "c++ std", "std:: c++" "namespace std:: c++", etc.

I admit that the use of the abbreviation is odd. Funny in a sense that
abbreviation itself presents an embarrassing name collision--the very
thing that it tries to avoid :-)

Regards,
Ben
May 15 '06 #4
from a practical point of view. If you not already using std::cout
then you probably have a line at the top of your code ' using namespace
std' Basically this line of code tells the compiler that you are using
the standard library and wherever it sees cout it must assume you mean
std::cout.

May 15 '06 #5
In message <11*********************@y43g2000cwc.googlegroups. com>,
wg*****@gmail.com writes
from a practical point of view. If you not already using std::cout
then you probably have a line at the top of your code ' using namespace
std' Basically this line of code tells the compiler that you are using
the standard library and wherever it sees cout it must assume you mean
std::cout.


No, that would be "using std::cout;". "using namespace std;" is more
general than that. Wherever it sees a name it will now look in std _as
well as_ everywhere else it would search. If you have an object called
cout in some other namespace, it may find that instead - the rules are
complicated.

--
Richard Herring
May 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Steven T. Hatton | last post: by
12 posts views Thread by Steven T. Hatton | last post: by
10 posts views Thread by Jim Langston | last post: by
6 posts views Thread by Magcialking | last post: by
5 posts views Thread by pkirk25 | last post: by
4 posts views Thread by Vince C. | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.