|
-
March 15th, 2011, 03:22 PM
#2
Re: Header files
In some cases, C header files like <math.h> have a different name in C++. So <cmath> is the C++ version of <math.h>, <cstdio> is the C++ name of C's <stdio.h>, etc. There may or may not be an actual difference in the content of the files, it's just good practice to select the right header for the language you're using.
In certain other cases, both standard and pre-standard versions of a header may be available. Some compilers still support <iostream.h>, a pre-standard header (which is still encouraged by a depressingly large number of tutorials), but the correct standard header is <iostream> and has been for years. Don't use pre-standard headers, as a rule.
There's at least one potentially confusing case. The C header <string.h> is available to C++ as <cstring>, but C++ *also* provides a <string> header, which contains the std::string class. So <cstring> and <string> are very different headers, but one of them is almost the same as <string.h>. Also note that the MFC class "CString" is not associated with any of these standard headers.
Last edited by Lindley; March 15th, 2011 at 04:18 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|