Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

depreciated <iostream.h>

Status
Not open for further replies.

asm1

Technical User
Oct 9, 2003
77
0
0
GB
Hi all,
I have a question but not sure if I am in the right forum, so please let me know if there is a more appropriate one to ask the question. I am messing with c++ from a book (C++ for Linux) and when I compile the programme below with the command “gcc cplus.cpp –o myoutput” I get stuff about the <iostream.h> it says that I am using one of 32 headers found in section 17.4.1.2 of the c++ standard and that it is depreciated or antiquated. So my question is what should I use instead of <iostream.h> thx in advance.

the programme was
Code:
#include <iostream.h>

int main()
{
	unsigned short  shortvar=5;
	unsigned long longvar=65535;
	long svar = -65535;
	

	cout << &quot;shortvar :\t&quot; <<shortvar;
	cout << &quot; Address of shortvar :\t&quot;;
	cout << &shortvar << &quot;\n&quot;;

	cout << &quot;longvar :\t&quot; << longvar;
	cout << &quot; Address of longvar :\t&quot;;
	cout << &longvar << &quot;\n&quot;;

	cout << &quot;svar : \t&quot; << svar;
	cout << &quot; Address of svar : \t&quot;;
	cout << &svar << &quot;\n&quot;;
	return 0;
}


The tougher it gets the more you learn! The more you learn the tougher it gets!
 
It's not depreciated, it's deprecated.

Use <iostream> (no .h) instead.
 
Of course, <iostream.h> isn't deprecated or depreciated! It was never standard in the first place, so it cannot be deprecated - deprecated means that it is still standard behavior but might be removed in the future.

The Standard C Library headers with the '.h' are deprecated. So technically they are still standard, but you should use the new versions because in the future the old versions might be removed from the standard (e.g. use <cstdlib> instead of <stdlib.h> and use <cmath> instead of <math.h>).

The old C++ library headers (e.g. <iostream.h>, <fstream.h>) are just plain not standard. It is definitely a good idea to use the new headers as chipperMDW stated. You will have to pay attention to the std namespace, but a simple search here or on the net should get you enough information to continue.
 
ok thanks for pointing that out, i will alter my screen res to better my reading. i will do a search for the new standards on google. thanks again

The tougher it gets the more you learn! The more you learn the tougher it gets!
 
And if you do use a non-standard, because of no other option, you may consider compiling with the -static option to make sure that your code will still run on newer machines that may not (later) have those libraries.
 
ok thanks i will look into -static

The tougher it gets the more you learn! The more you learn the tougher it gets!
 
It's not a fix all, and it will generate larger files... but it's sometimes a usefull tool.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top