By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,491 Members | 3,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,491 IT Pros & Developers. It's quick & easy.

iostream.h with ms visual c++ 6.0?

P: n/a
Hello,

I want to use a tutorial to take first steps. I use MS Visual c++ 6.0 and
Win 98. When I try to compile a "hello world" program using the <iostream.h>
library and cout << "hello world", the compiler tells me that "cout" is an
undeclared identifier. But it does not tell me that including iostream.h
causes any problems. I read in a german newsgroup that instead of
<iostrem.h>, simply <iostrem> has to be included under MS Visual C++ and
that std::cout must be used. But when I try this, the compiler says
referring to #include <iostream>: "eh.h is only for C++". What should I do?

thank you very much in advance,

Moritz
Jul 22 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a

"Moritz Steinberger" <mo***************@yahoo.de> wrote in message
news:c1*************@news.t-online.com...
Hello,

I want to use a tutorial to take first steps. I use MS Visual c++ 6.0 and
Win 98. When I try to compile a "hello world" program using the <iostream.h> library and cout << "hello world", the compiler tells me that "cout" is an
undeclared identifier. But it does not tell me that including iostream.h
causes any problems. I read in a german newsgroup that instead of
<iostrem.h>, simply <iostrem> has to be included under MS Visual C++ and
that std::cout must be used. But when I try this, the compiler says
referring to #include <iostream>: "eh.h is only for C++". What should I

do?

If your source code file ends with .c it is compled as "C" code and not
"C++", use .cpp as the file extension to compile as "C++". Or configure VC
to work the way you prefere.

#include <iostream> is the proper C++ form. Also remember cout is in
namespace std. So you will need to std::cout.

Jeff F
Jul 22 '05 #2

P: n/a

"Moritz Steinberger" <mo***************@yahoo.de> wrote in message
news:c1*************@news.t-online.com...
Hello,

I want to use a tutorial to take first steps. I use MS Visual c++ 6.0 and
Win 98. When I try to compile a "hello world" program using the <iostream.h> library and cout << "hello world", the compiler tells me that "cout" is an
undeclared identifier. But it does not tell me that including iostream.h
causes any problems. I read in a german newsgroup that instead of
<iostrem.h>, simply <iostrem> has to be included under MS Visual C++ and
that std::cout must be used. But when I try this, the compiler says
referring to #include <iostream>: "eh.h is only for C++". What should I do?
thank you very much in advance,

Moritz


Make sure you're filename is called something.cpp. It sounds like you are
invoking the C compiler not the C++ compiler.

The advice about <iostream> or <iostream.h> is true of all compilers. Only
<iostream> is correct C++.

john
Jul 22 '05 #3

P: n/a
Moritz Steinberger wrote:

I want to use a tutorial to take first steps. I use MS Visual c++ 6.0 and
Win 98. When I try to compile a "hello world" program using the <iostream.h>
library and cout << "hello world", the compiler tells me that "cout" is an
undeclared identifier. But it does not tell me that including iostream.h
causes any problems. I read in a german newsgroup that instead of
<iostrem.h>, simply <iostrem> has to be included under MS Visual C++ and
iostream.h is an old header that should not be used anymore.
Please do as suggested in that newsgroup.

Also, you might want to get a good book to learn C++.
"Accelerated C++" is very recommended for starters.
that std::cout must be used. But when I try this, the compiler says
referring to #include <iostream>: "eh.h is only for C++". What should I do?


Your question is offtopic here, because you have problems
with a particular compiler, not the language itself.

Please ask compilerspecific questions in the appropriate
NGs, e.g. microsoft.public.de.vc (A german ng dedicated to VC++)
Nonetheless, your problem arises because you have named your
sourcefile .c the compiler thinks you want to program in C.

So simply rename your sourcefile to .cpp and it should work.

hth

Christoph
Jul 22 '05 #4

P: n/a
Hello,
Please do as suggested in that newsgroup.
I did as Mr. Harrison and Mr. Flinn told me here and it works fine now.
Thank you, Mr. Rabel, Mr. Harrison and Mr. Flinn.
Also, you might want to get a good book to learn C++.
"Accelerated C++" is very recommended for starters.
Well I checked several books, one even called "C++ for dummies", but I seem
to be even too dummy-like for the latter. Then I found a tutorial on www.
cplusplus.com which I would like to recommend to anyone who is an absolute
beginner or who knows such people and wants to give them some advice.
Your question is offtopic here, because you have problems
with a particular compiler, not the language itself.
I'm sorry for that, I just didn't realize the differences between C, C++ and
the Microsoft Visual C++ compiler.
Please ask compilerspecific questions in the appropriate
NGs, e.g. microsoft.public.de.vc (A german ng dedicated to VC++)


I'll do so in the future, thank you.

Moritz
Jul 22 '05 #5

P: n/a
KTC
"Moritz Steinberger" <mo***************@yahoo.de> for some reason
wrote:

Well I checked several books, one even called "C++ for dummies",
but I seem to be even too dummy-like for the latter. Then I
found a tutorial on www.cplusplus.com which I would like to
recommend to anyone who is an absolute beginner or who knows
such people and wants to give them some advice.


DON'T try to learn C++ from "C++ for dummies", it would do you more
harm than good (if it does you any good at all...).

The tutorial down at cplusplus.com is quite good EXCEPT for the fact
that it doesn't use the correct header name of <iostream> and instead
use <iostream.h> which as have already been said is wrong.

The only tutorial I can find on the internet that even use the
correct header is http://cplus.about.com/library/blcplustut.htm . It
seems quite good to me although some good books is still recommanded
as the way to learn.

Take a look at http://www.accu.org/bookreviews/public/index.htm for
some books review.
KTC

--
Experience is a good school but the fees are high.
- Heinrich Heine
Jul 22 '05 #6

P: n/a
> Your question is offtopic here, because you have problems
with a particular compiler, not the language itself.
I'm trying to figure out why this question is off topic here?

1) The extensionless headers is (in my opinion) a very poor decision on the
standards committee. Originally, before standardized, the headers *DID* have a
..h extension, and library implementors based their headers on that fact. Then,
the committee later changed to extensionless (if I recall correctly, it was
originally a mistake/unintended omission, but no one on the committee made
enough of a fuss about it, so it just stayed).

Other than Apple operating systems, I'm not aware of any os that doesn't use an
extensions to identify file types, although I'll be first to admit that my os
experience is primarily limited to the os that is found on 90% of desktop
systems.

The extension/extensionless issue is something that isn't compiler specific,
but is negative fallout of the slow standardization process that plagued C++
during the 90s.

2) All C++ compilers I've ever used (maybe 5), have defaulted to compiling C
code for .c files and C++ for .cpp files. Again, I don't think that this issue
is compiler-specific in any way.

Christoph Rabel wrote:
Moritz Steinberger wrote:

I want to use a tutorial to take first steps. I use MS Visual c++ 6.0 and
Win 98. When I try to compile a "hello world" program using the <iostream.h>
library and cout << "hello world", the compiler tells me that "cout" is an
undeclared identifier. But it does not tell me that including iostream.h
causes any problems. I read in a german newsgroup that instead of
<iostrem.h>, simply <iostrem> has to be included under MS Visual C++ and


iostream.h is an old header that should not be used anymore.
Please do as suggested in that newsgroup.

Also, you might want to get a good book to learn C++.
"Accelerated C++" is very recommended for starters.
that std::cout must be used. But when I try this, the compiler says
referring to #include <iostream>: "eh.h is only for C++". What should I do?


Your question is offtopic here, because you have problems
with a particular compiler, not the language itself.

Please ask compilerspecific questions in the appropriate
NGs, e.g. microsoft.public.de.vc (A german ng dedicated to VC++)

Nonetheless, your problem arises because you have named your
sourcefile .c the compiler thinks you want to program in C.

So simply rename your sourcefile to .cpp and it should work.

hth

Christoph

Jul 22 '05 #7

P: n/a
>
1) The extensionless headers is (in my opinion) a very poor decision on the standards committee. Originally, before standardized, the headers *DID* have a .h extension, and library implementors based their headers on that fact. Then, the committee later changed to extensionless (if I recall correctly, it was originally a mistake/unintended omission, but no one on the committee made
enough of a fuss about it, so it just stayed).


Really, where do you recall this from? I'm not doubting you, just interested
in your source of information.

john
Jul 22 '05 #8

P: n/a
> Really, where do you recall this from? I'm not doubting you, just interested
in your source of information.
Feel free to doubt -- I'm going from memory on this one from about 8 years ago,
and I can barely remember my name day to day...

I can't remember where I heard it -- I just know at the time that I first heard
about extensionless headers, I thought it was a bad idea and tried to find out
the motivation. I just did a quick search on Google and couldn't turn up
anything. Perhaps someone that remembers better than I can either confirm/deny
my thought on the subject...

John Harrison wrote:

1) The extensionless headers is (in my opinion) a very poor decision on

the
standards committee. Originally, before standardized, the headers *DID*

have a
.h extension, and library implementors based their headers on that fact.

Then,
the committee later changed to extensionless (if I recall correctly, it

was
originally a mistake/unintended omission, but no one on the committee made
enough of a fuss about it, so it just stayed).


Really, where do you recall this from? I'm not doubting you, just interested
in your source of information.

john

Jul 22 '05 #9

P: n/a
"Julie" <ju***@aol.com> wrote in message news:40***************@aol.com...
Your question is offtopic here, because you have problems
with a particular compiler, not the language itself.
I'm trying to figure out why this question is off topic here?

1) The extensionless headers is (in my opinion) a very poor decision on

the standards committee. Originally, before standardized, the headers *DID* have a .h extension, and library implementors based their headers on that fact. Then, the committee later changed to extensionless (if I recall correctly, it was originally a mistake/unintended omission, but no one on the committee made
enough of a fuss about it, so it just stayed).
Hardly. It was a concerted decision by the Library Subgroup that I opposed
vehemently. It certainly didn't happen by accident. I don't much care for
it to this day, but it's what the committee decided on, so it's Standard
C++ now.
Other than Apple operating systems, I'm not aware of any os that doesn't use an extensions to identify file types, although I'll be first to admit that my os experience is primarily limited to the os that is found on 90% of desktop
systems.

The extension/extensionless issue is something that isn't compiler specific, but is negative fallout of the slow standardization process that plagued C++ during the 90s.
I don't see how the slowness of the process caused this particular decision.
It's not like the extensions withered on the vine...
2) All C++ compilers I've ever used (maybe 5), have defaulted to compiling C code for .c files and C++ for .cpp files. Again, I don't think that this issue is compiler-specific in any way.


I believe the Topic Police leapt at the chance to decree iostream.h Off
Topic (TM) because there's no mention of that header in the C++ Standard.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 22 '05 #10

P: n/a

"Julie" <ju***@aol.com> wrote in message news:40***************@aol.com...
Really, where do you recall this from? I'm not doubting you, just interested
in your source of information.
Feel free to doubt -- I'm going from memory on this one from about 8 years

ago, and I can barely remember my name day to day...

I can't remember where I heard it -- I just know at the time that I first heard about extensionless headers, I thought it was a bad idea and tried to find out
the motivation. I just did a quick search on Google and couldn't turn up
anything. Perhaps someone that remembers better than I can either confirm/deny my thought on the subject...


I can't recall anything to that effect. All I remember is that Mr. Andrew Koenig
proposed
the idea of extensionless headers to the committee.
Jul 22 '05 #11

P: n/a
I'll gladly stand corrected, as I've said, I'm going from 8 year old memory on
this one.

The headers were originally .h, right? and then were subsequently changed (all
prior to standardization).

"P.J. Plauger" wrote:

"Julie" <ju***@aol.com> wrote in message news:40***************@aol.com...
Your question is offtopic here, because you have problems
with a particular compiler, not the language itself.


I'm trying to figure out why this question is off topic here?

1) The extensionless headers is (in my opinion) a very poor decision on

the
standards committee. Originally, before standardized, the headers *DID*

have a
.h extension, and library implementors based their headers on that fact.

Then,
the committee later changed to extensionless (if I recall correctly, it

was
originally a mistake/unintended omission, but no one on the committee made
enough of a fuss about it, so it just stayed).


Hardly. It was a concerted decision by the Library Subgroup that I opposed
vehemently. It certainly didn't happen by accident. I don't much care for
it to this day, but it's what the committee decided on, so it's Standard
C++ now.
Other than Apple operating systems, I'm not aware of any os that doesn't

use an
extensions to identify file types, although I'll be first to admit that my

os
experience is primarily limited to the os that is found on 90% of desktop
systems.

The extension/extensionless issue is something that isn't compiler

specific,
but is negative fallout of the slow standardization process that plagued

C++
during the 90s.


I don't see how the slowness of the process caused this particular decision.
It's not like the extensions withered on the vine...
2) All C++ compilers I've ever used (maybe 5), have defaulted to compiling

C
code for .c files and C++ for .cpp files. Again, I don't think that this

issue
is compiler-specific in any way.


I believe the Topic Police leapt at the chance to decree iostream.h Off
Topic (TM) because there's no mention of that header in the C++ Standard.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com

Jul 22 '05 #12

P: n/a
"Julie" <ju***@aol.com> wrote in message news:40***************@aol.com...
I'll gladly stand corrected, as I've said, I'm going from 8 year old memory on this one.

The headers were originally .h, right? and then were subsequently changed (all prior to standardization).


Yes, there was certainly an iostream.h. The argument during standardization
was that some people used *.h, some *.hpp, and some even other suffixes for
C++ headers. So the "compromise" was to render all of them nonconforming
by having no suffix at all.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 22 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.