I'm using the string and the iostream header file. When I tried to use the
iostream.h the cout command would not compile but the iostream does. Why is
this? What is the difference between iostream and iostream.h???
Also I am using ms visual C++ and have found for the string command to work
I have to use the line
'using workspace std;'
What does this line actually do, except from getting the program to
compiled.
Many thanks
iostream is the correct header
iostream.h is a depreciated header for compatabilty with older compilers
that should be
using namespace std;
also header for string in c++
is
#include <string>
to use c style strings
#include <cstring>
more information
http://www.comeaucomputing.com/techtalk/#cname
from the welcome to comp.lang.c++
http://members.nbci.com/jshiva/welcome.txt
++Include the smallest, complete and compilable program that exhibits your
problem. As a rule, posters in comp.lang.c++ will not do homework, but
will
give helpful hints if you have shown some willingness to try a
solution.Take
a look at http://members.xoom.com/jshiva/hw.txt
Alex
http://www.faqs.org/faqs/C-faq/learn/ alt.comp.lang.learn.c-c++
http://www.eskimo.com/~scs/C-faq/top.html comp.lang.c
http://marshall-cline.home.att.net/cpp-faq-lite/ comp.lang.c++
http://members.xoom.com/jshiva/welcome.txt
http://www.geocities.com/alxx9672/learnc.html al's c and c++ links page
If you mean deprecated, rather than depreciated, then that's incorrect for
<iostream.h>. The standard does include a number of deprecated headers but
<iostream.h> is not one of them. You're correct, of course, about many
compilers including <iostream.h> for compatibility with existing code.
Dim
<iostream.h> is an older, non-standard, version of the <iostream> header. In
fact, because it's not part of the C++ standard there may be many versions
of <iostream.h>, all similar but potentially different which is a
portability issue.
<iostream> is the C++ standard header. Assuming that your compiler has this
header, and all recent compilers should have, you should prefer its use
over <iostream.h> unless you specifically need <iostream.h> for
compatilibity with existing code.
By the way, there are no 'commands' in C++.
> Also I am using ms visual C++ and have found for the string command
> to work I have to use the line
> 'using workspace std;'
>
> What does this line actually do, except from getting the program to
> compiled.
You'll find that such things as cout and string from the standard library
are in namespace std. In order to use them you will have to include the
appropriate headers and also qualify their use with the std:: prefix, e.g.:
std::cout << "Hello, World" << std::endl;
An alternative to this would be to use a using declaration, e.g.:
using std::cout;
This avoids having to use the std:: prefix whenever you use cout.
A further option is to use a using directive, e.g.:
using namespace std;
In doing this you are making all of the contents of namespace std available
without qualification.
Dim
Well, one could validly argue that <iostream.h> was implicitly deprecated,
but yes, you're right, C's name.h are explicitly deprecated by
Standard C++ in favor of <Cname> headers. To the OP: some more
info can be found at
http://www.comeaucomputing.com/techtalk/#cname
As to the full breath and width of what 'using namespace std;' does
(note namespace not workspace), you really need a good C++ text
that discussed not only the syntax but the conceptual premise of
namespaces. For that, you might want to check out
http://www.comeaucomputing.com/booklist
--
Greg Comeau Comeau C/C++ 4.2.45 "so close"
ONLINE COMPILER ==> http://www.comeaucomputing.com/tryitout
4.2.45.2 during March! NEW ONLINE: Try out our C99 mode!
com...@comeaucomputing.com http://www.comeaucomputing.com
One might validly argue that the explicitly deprecated headers are
'normative for the current issue of the standard' whilst <iostream.h> is
not. I personally wouldn't use the term 'implicitly deprecated' for such a
header for that reason.
Dim
I absolutely agree that one could argue that.
>I personally wouldn't use the term 'implicitly deprecated' for such a
>header for that reason.
I didn't say it was normatively implicitly deprecated, all I said
was that one could _argue_ that there are implicit deprecations too.
The thing is that there has only been one Standard C++,
so explicitly deprecating features tends to have a oxymoron'ish flavor
since it begs the question "Deprecated compares to what?"
Anyway, I agree that <iostream.h> is not part of Standard C++
and that whereas say <stdio.h> is, it is deprecated and
<cstdio> is the suggested alternative.