Question about writing a program in visual c++

Status
Not open for further replies.
that means that the same code slvrstang wrote would function with or without "using namespace std:" when i am using a newer version of c++...right?

Yes, its programmer's choice to use namespace in the program. [ I mean the 'std' one ]

 
Ok, using #include <iostream> versus #include <iostream.h> is really just an ECMA standard. All newer versions of C++ require that you DO NOT include the ".h" on all your #include statements. So, if find a tutorial that uses them, it's probably outdated.

As for using namepsace std;
Namespaces really just "package" up different variable names. For example, if two companies created different parts to the same program, and both wanted to name a certain variable "browser" it would be impossible, because the compiler wouldn't know which version of browser to use. So they use namespaces, tht would look like this:

Assume there are two companies, both have created a header file which has it's own namespace to resolve naming conflicts. CompnayA's namespace is "web" companyB's namespace is "dsk" they could then write their code like this...

Code:
#include <companya>
#include <companyb>

web::browser;  // <-- that is company A's variable
dsk::browser; // <-- That is company b's vairable

I hope that makes sense to you :)

If you didn't use the "using namespace std;" line then everytime you write "cout" or "cin" you'd actually have to write "std::cout" or "std::cin" which is a whole lot more typing, so you include the using directive to shorten it. It tells the compiler "Hey, I'll be using the std:: namespace so everytime I use something from that package, just know that, that's where I'm getting it from. Ok, thanks bye!"
 
thx for the infos u stuffed here dudes, really helped me out
i've regained my trust to help from forums again :D
 
Status
Not open for further replies.
Back
Top Bottom