Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Cire

STD

This topic is 5960 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is using STD in front of cout or anything, absolutely necessary if i have microsoft visual c++ compiler?

Share this post


Link to post
Share on other sites
Advertisement
Somehow you must specify the namespace (using namespace std, using std::whatver, or std::whatever) or you''re not using standard C++. When asking a question about standard C++ you shouldn''t bring up the compiler.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Like the way you put your functions into ''cateogories'' by putting them into classes and files into folders, namespaces are just a way of putting related code into categories. The C++ standard dictates that all standard library code must be placed into the std namespace. It does have its advantages.

It is easier to see by looking at your code how things relate (e.g. that''s in the sound namespace so it must be part of sound effects library), and it also stops name clashes developing (e.g. you can have two functions with the same name in different namespaces).

Imagine a C graphics library called ABC that has a functions called things like ABC_Flip. The ABC_ prefix would be used on all functions because here the Flip identifier is perhaps too short to avoid clashes when others use it in their code. Namespaces help get rid of this kind of pollution of your identifier names.

Try not to look on them as a pointless feature that gets in the way; it can make your code nicer.

Share this post


Link to post
Share on other sites
It''s worth noting that MS''s iostream.h header does not place its contents into namespace std. Some people seem to think that is the only difference between iostream and iostream.h. It''s not.

Share this post


Link to post
Share on other sites
I didn''t know a compiler could get an STD. Well, no wonder mines been acting so strange; it must have gotten syphilis!!

(I know, that''s an 8th grader joke, but when I saw STD, I thought, "Sexually Transmitted Disease

Share this post


Link to post
Share on other sites
Well, yeah, especially from the capitalization. He probably whines about C++''s case sensitivity since he can''t manage just to copy something as simple as 3 letters verbatim.

Share this post


Link to post
Share on other sites
Isn''t it possible to get rid of ''std::'' everywhere by using the ''using namespace std'' declaration in the code?

Have a nice day,


---
Never trust a Troglotroll.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!