Click here to Skip to main content
15,076,130 members
Articles / Programming Languages / C++
Posted 28 Jun 2010

Tagged as


5 bookmarked

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

Rate me:
Please Sign up or sign in to vote.
4.75/5 (28 votes)
18 Aug 2011CPOL
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.


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


About the Author

United States United States
No Biography provided

Comments and Discussions

GeneralI do not suggest always upgrading a library. Be sure to upgr... Pin
BrainlessLabs.com30-Dec-11 7:28
MemberBrainlessLabs.com30-Dec-11 7:28 
GeneralReason for my vote of 5 I love CP because it has people like... Pin
Pranit Kothari20-Dec-11 3:50
MemberPranit Kothari20-Dec-11 3:50 
GeneralReason for my vote of 5 Very imp info. Pin
PrafullaVedante10-Nov-11 20:00
MemberPrafullaVedante10-Nov-11 20:00 
GeneralReason for my vote of 5 Very helpful tip! Pin
User 641634323-Aug-11 2:30
MemberUser 641634323-Aug-11 2:30 
GeneralReason for my vote of 2 really banal info Pin
bearw0822-Aug-11 21:57
Memberbearw0822-Aug-11 21:57 
GeneralReason for my vote of 5 Thanks for the info. As a new progra... Pin
KenBonny22-Aug-11 20:59
MemberKenBonny22-Aug-11 20:59 
GeneralI had assumed that it was just an alias. Good to know there'... Pin
lewax0019-Aug-11 6:14
Memberlewax0019-Aug-11 6:14 
GeneralReason for my vote of 5 Wow, i did not know that. i am going... Pin
ryan20fun18-Aug-11 23:17
Memberryan20fun18-Aug-11 23:17 
GeneralReason for my vote of 3 This is common knowledge; but, never... Pin
George L. Jackson20-Aug-10 1:49
MemberGeorge L. Jackson20-Aug-10 1:49 
GeneralReason for my vote of 2 simple but worths knowing.. Pin
Cool_Dev11-Aug-10 5:02
MemberCool_Dev11-Aug-10 5:02 
GeneralReason for my vote of 5 Nice to know! :) Pin
Bigdeak30-Jun-10 22:05
MemberBigdeak30-Jun-10 22:05 
GeneralThe .h headers were standardised 12 years ago, even Microsof... Pin
Aescleal29-Jun-10 3:13
MemberAescleal29-Jun-10 3:13 
GeneralRe: Agreed, i believe even .h version of iostream is not availab... Pin
ThatsAlok3-Jan-12 3:11
MemberThatsAlok3-Jan-12 3:11 
GeneralReason for my vote of 5 Very Nice info. Pin
GPUToaster™28-Jun-10 18:47
MemberGPUToaster™28-Jun-10 18:47 
GeneralNice Info :) Pin
GPUToaster™28-Jun-10 18:47
MemberGPUToaster™28-Jun-10 18: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.