|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Registered User
Join Date: Nov 2001
Posts: 1,965
|
Standard C++
Recently I read that header files ending with .h (like iostream.h) aren't standard any more, and that standard code uses the .h-free versions, can anybody explain or give a link to explanation on the difference and how to migrate to the new version?
Thanks in advance. |
|
|
|
|
|
#2 |
|
Member (9 bit)
|
where did you read this? I know that the standard c libraries now have the common convention of no .h but every other library is expected to have .h. I have never heard that this was standard but that it was a common convention like calling your integers nMyInteger.
HTH |
|
|
|
|
|
#3 |
|
Member (12 bit)
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
|
It's part of the "new" ANSI C++. And I say "new" only because when I learned ANSI C++, it didn't exist (and my compiler is too old to even allow things like #include <cstdio> instead of the older #include <stdio.h>).
Any new book should teach ANSI C++, with things like the std namespace, etc. Last edited by Paul Victorey; 08-23-2002 at 07:34 PM. |
|
|
|
|
|
#4 |
|
Member (7 bit)
Join Date: Jul 2000
Location: Australia
Posts: 97
|
As I recall this is the new standard when including stream library header files when using the new stream libraries.
If you wan't to use the old stream libraries, just add the .h extention. Note : You cannot use the old and new stream library headers at the same time. It will cause a lot of headache during compilation and linking. |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Nov 2001
Posts: 1,965
|
And the rest is exactly the same or what?
Is it only a matter of removing .h? |
|
|
|
|
|
#6 |
|
Member (7 bit)
Join Date: Jul 2000
Location: Australia
Posts: 97
|
When using standard c++ libraries don't include the .h extenstion. ( streams, stl, etc. )
When using standard c libraries include the .h extenstion. As for the csdtio, as Paul mentioned is a new ansi C++ specification, which would mean the cstdio is a standard C++ library header file thus no .h extension is needed. In addition I think that this cstdio header file was created so that C++ code can include the stdio libraries and conform with the new way of including header files, to make include declaration in C++ uniform. Hope this helps. |
|
|
|
|
|
#7 |
|
Member (12 bit)
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
|
Also, if you're using the new standards, you will need to include the std namespace to make it work like it used to. Otherwise, you'd need to use things like std::cout << "Test";
|
|
|
|
|
|
#8 |
|
Member (7 bit)
Join Date: Jul 2000
Location: Australia
Posts: 97
|
I like adding the namespace in front of the operation of the class being called, instead of declaring a "using namespace". It tells me more detail of which namespace the operatoin belongs to, but then again it's depends on the developer.
Besides it makes you type more, which in effect looks like you are lot busier .
|
|
|
|
|
|
#9 |
|
Member (12 bit)
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
|
Hehe, I'm sure I'd use the namespace, once I manage to get a decent compiler that supports the newest standards. I use Borland C++ 5.02 which is great(it was free and had a very nice gui/IDE).
I've seen some people who have managed to use the newer Borland compilers as a back-end to the 5.02 IDE, but it didn' t work for me, I may need to reinstall BC5 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|