Click here to Skip to main content
12,630,137 members (26,659 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

30.7K views
5 bookmarked
Posted

C++ Tip : Should I use iostream.h or iostream?

, 18 Aug 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Minor edits to improve wording
Many C++ programmers still use <iostream.h> instead of the newer, standard compliant <iostream> library. What are the differences between the two?
  • The .h notation of standard header files was deprecated more than five years ago. Using deprecated features in new code is never a good idea.
  • In terms of functionality, <iostream> contains a set of templatized I/O classes which support both narrow and wide characters, as opposed to <iostream.h> which only supports char-oriented streams.
  • The C++ standard specification for iostream’s interface was changed, with many subtle aspects. Consequently, the interfaces and implementation of <iostream> differ from those of <iostream.h>.
  • <iostream> components are declared in namespace std whereas <iostream.h> components are in global scope (chances of name conflicts are greater).
For these reasons, you should never mix the two libraries in one program. As a rule of thumb, use the newer <iostream> header file, unless you are dealing with legacy code that is only compatible with <iostream.h>. Otherwise, my suggestion is always to upgrade from the older version to newer version, which is quite easy to do.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

elitehussar
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralI do not suggest always upgrading a library. Be sure to upgr... Pin
Shakti Misra30-Dec-11 8:28
memberShakti Misra30-Dec-11 8:28 
GeneralReason for my vote of 5 I love CP because it has people like... Pin
Pranit Kothari20-Dec-11 4:50
memberPranit Kothari20-Dec-11 4:50 
GeneralReason for my vote of 5 Very imp info. Pin
PrafullaVedante10-Nov-11 21:00
memberPrafullaVedante10-Nov-11 21:00 
GeneralReason for my vote of 5 Very helpful tip! Pin
no.reason23-Aug-11 3:30
memberno.reason23-Aug-11 3:30 
GeneralReason for my vote of 2 really banal info Pin
bearw0822-Aug-11 22:57
memberbearw0822-Aug-11 22:57 
GeneralReason for my vote of 5 Thanks for the info. As a new progra... Pin
KenBonny22-Aug-11 21:59
memberKenBonny22-Aug-11 21:59 
GeneralI had assumed that it was just an alias. Good to know there'... Pin
lewax0019-Aug-11 7:14
memberlewax0019-Aug-11 7:14 
GeneralReason for my vote of 5 Wow, i did not know that. i am going... Pin
ryan20fun19-Aug-11 0:17
memberryan20fun19-Aug-11 0:17 
GeneralReason for my vote of 3 This is common knowledge; but, never... Pin
George L. Jackson20-Aug-10 2:49
memberGeorge L. Jackson20-Aug-10 2:49 
GeneralReason for my vote of 2 simple but worths knowing.. Pin
Cool_Dev11-Aug-10 6:02
memberCool_Dev11-Aug-10 6:02 
GeneralReason for my vote of 5 Nice to know! :) Pin
Bigdeak30-Jun-10 23:05
memberBigdeak30-Jun-10 23:05 
GeneralThe .h headers were standardised 12 years ago, even Microsof... Pin
Aescleal29-Jun-10 4:13
memberAescleal29-Jun-10 4:13 
GeneralRe: Agreed, i believe even .h version of iostream is not availab... Pin
ThatsAlok3-Jan-12 4:11
memberThatsAlok3-Jan-12 4:11 
GeneralReason for my vote of 5 Very Nice info. Pin
GPUToaster28-Jun-10 19:47
memberGPUToaster28-Jun-10 19:47 
GeneralNice Info :) Pin
GPUToaster28-Jun-10 19:47
memberGPUToaster28-Jun-10 19:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161205.3 | Last Updated 18 Aug 2011
Article Copyright 2010 by elitehussar
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid