Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Question about writing a program in visual c++
Closed Thread
Old 11-25-2004, 10:32 PM   #11 (permalink)
 
Ultra Techie

Join Date: Jun 2004

Posts: 973

intercodes

Send a message via Yahoo to intercodes
Default

Quote:
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 ]


intercodes is offline  
Old 11-26-2004, 10:00 AM   #12 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

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!"
__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 11-26-2004, 10:22 AM   #13 (permalink)
 
Newb Techie

Join Date: Nov 2004

Posts: 38

DemonEdge

Default

thx for the infos u stuffed here dudes, really helped me out
i've regained my trust to help from forums again
DemonEdge is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On