Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 namespace std and <iostream.h> vs <iostream>
Index -> Programming, C++ -> C++ Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mazer




PostPosted: Mon Mar 15, 2004 4:48 pm   Post subject: namespace std and <iostream.h> vs <iostream>

Just wondering how everyone feels about using #include <iostream.h> in their programs instead of #include <iostream>
But not just for iostream, for fstream and string and vector as well. I hear alot of talk about how you aren't supposed to include the .h at the end because those are old C headers, and the C++ headers (without .h in the name) are supposedly better. Of course, if I do use the headers without .h, it means I will need to use using namespace std, and as I've noticed, that can blow up my executable to at least 540kb (and all it does is load a 3D katana and spin it).

I'm sure there was something else I wanted to say, but a friend of mine distracted me with some pictures of Carmen Electra and...
Er, so, what do you guys think? Any comments about why it would be "bad practice" to utilize the "old" headers? What's your personal preference?
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Mon Mar 15, 2004 6:55 pm   Post subject: (No subject)

I use <iostream> and <string> and etc etc etc without the .h

I dunno, I guess it's Mr.Mckenzie's fault telling us to use those.
Tony




PostPosted: Mon Mar 15, 2004 8:23 pm   Post subject: (No subject)

i use <iostream> cuz it's shorter Laughing and you don't really have to use namespace... you could use std::cout instead Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mazer




PostPosted: Mon Mar 15, 2004 8:29 pm   Post subject: (No subject)

Yeah, but would you do that for every time you want to use cout? Adding std:: in front does cut down the size of the executable (who would've thought that an std could be a good thing... naoki Wink ) that you'd get by using the standard namespace, but if I have alot of stuff that is in the standard namespace, that gets kinda annoying. Right now I'm only using std:: for declaring vector class objects. Which is good because I only need to use it once each time.
wtd




PostPosted: Mon Mar 15, 2004 10:05 pm   Post subject: (No subject)

I always use <iostream>, <fstream>, <string>, <vector>, <list>, <algorithm> and such. It's the way of the future. The headers that end in .h might be there for legacy support, but make no mistake, that's the only reason they're there.

As for:

code:
using namespace std;


I don't mind using it quite as much in my main function, though I prefer not to. However, I generally prefer to never use it in a library, and I only ever use it inside a function, and never in the global namespace.
rizzix




PostPosted: Mon Mar 15, 2004 11:28 pm   Post subject: (No subject)

meh... no opinion
Tony




PostPosted: Tue Mar 16, 2004 12:44 am   Post subject: (No subject)

I think that you're a tool, mazer. Suicide is something that I'd consider if I were you. The slow and painful kind. C++ is for losers, turing all the way.


By the way, this is martin...err 'Darkness'

Love it or shove it.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
wtd




PostPosted: Tue Mar 16, 2004 12:57 am   Post subject: (No subject)

C++ is painful, but it's incredibly powerful.

"The more programming languages you know, the more you realize they all suck."
Mazer




PostPosted: Tue Mar 16, 2004 8:23 am   Post subject: (No subject)

tony wrote:
I think that you're a tool, mazer. Suicide is something that I'd consider if I were you. The slow and painful kind. C++ is for losers, turing all the way.


By the way, this is martin...err 'Darkness'

Love it or shove it.

LM ass O. Wink
As soon as you suggested suicide I kinda figured it would be Darkness, of course when you called me a tool I thought you might me James. And by that I mean, suicide would be a very good idea for you. Besides, tony wouldn't insult me, we're on the same team fighting Dan Shadow to get back the book of typos.
Tony




PostPosted: Wed Mar 17, 2004 12:34 am   Post subject: (No subject)

Your mom's on the same team fighting Shadow Dan. On a trampoline.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mazer




PostPosted: Wed Mar 17, 2004 8:14 am   Post subject: (No subject)

I hereby decree that the next post shall be directed at Martin.
Tony




PostPosted: Wed Mar 17, 2004 11:33 am   Post subject: (No subject)

Your mom puts the tramp into trampoline
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Thuged_Out_G




PostPosted: Tue Mar 23, 2004 5:49 pm   Post subject: (No subject)

tony wrote:
Your mom puts the tramp into trampoline


odd, but i thought i had heard a rumor about you being conceived on a trampoline Wink Laughing

jk lol
jonos




PostPosted: Tue Mar 23, 2004 9:00 pm   Post subject: (No subject)

wqow this is interesting. i use the .h just because the first tut i found had that... but my sams book (which is not the best) says that you don't have to have the .h because the compiler knows what you mean, which i think may be wrong, but sams has a lot of books.
jonos




PostPosted: Tue Mar 23, 2004 10:26 pm   Post subject: (No subject)

to all you advanced c++ers, would you recommend using:

using namespace std;

or by using:

std:: cout << "hello people " << std::endl;

becaue though it may take longer to type, ive read some things agaist "using namespace std;".

what would be the best practice to get into?
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 23 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: