N
Newsnet Customer
Hi,
Which system header file do I unclude in order to use the new string data
type?
KJ
Which system header file do I unclude in order to use the new string data
type?
KJ
2) I assume system header files provides implementations unlike user-defined
header files, which are just interfaces.
No, the system header files are generally just interfaces also. An
exception may be the header files that declare template classes, because
many or most compilers don't support separate compilation of templates.
The implementations are usually in a compiled library file that your
compiler automatically links to your compiled code.
That's not a question. As an assumption, it's incorrect. For a start, in
the statement '#include <string>', the word 'string' is not a filename.
The necessary declarations, etc., may or may not be stored in a file.
Newsnet Customer said:if string is not a filename then what file is it actually including in this
case? an object string?
Mike Wahler said:A compiler is free to provide these delcarations any
way at all, e.g. via a file, 'hard coded' into the
compiler, or any other way at all. It's very common
for standard headers to be represented with files,
but not at all required.
Newsnet Customer said:if string is not a filename then what file is it actually including in this
case? an object string?
Buster Copley said:0Newsnet Customer wrote: ,snip>
That said, in many cases there will be a header file called 'string'.
And because separate compilation of templates is so tricky, the chances
are most of the implementation will be available just from including the
appropriate header. User header files may also include templates and
inline functions.
Newsnet said:Right, so your saying that by including:
#include <string>
the compiler's preprocessor will include the contents of the <string> header
file into the source, then compile the entire source file, and then link it
with whatever file it neeeds (in this case, string.cpp). Is this what you
mean?
The name of the *header* is <string>. The statement:
#include <string>
Is simply required to cause the compiler to provide
all declarations the language specifies it must, at
the scope where the #include directive appears.
A compiler is free to provide these delcarations any
way at all, e.g. via a file, 'hard coded' into the
compiler, or any other way at all. It's very common
for standard headers to be represented with files,
but not at all required.
I asummed that if the header does not have an extension associated with it
then it's not a file, which leaves me thinking what <string> represents. I
don't think you have exactly told me that, but it appears that it could be
'hard-coded' into the compiler.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.