使用ms visual c ++ 6.0的iostream.h? [英] iostream.h with ms visual c++ 6.0?

查看:81
本文介绍了使用ms visual c ++ 6.0的iostream.h?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我想用一个教程来迈出第一步。我使用MS Visual c ++ 6.0和

Win 98.当我尝试编译hello world时程序使用< iostream.h>

库和cout<< hello world,编译器告诉我cout。是一个

未声明的标识符。但它没有告诉我包括iostream.h

导致任何问题。我在德国新闻组中读到,而不是

< iostrem.h>,只需< iostrem>必须包含在MS Visual C ++和

下,必须使用std :: cout。但是当我尝试这个时,编译器说

引用#include< iostream>:eh.h仅适用于C ++。我该怎么办?


提前非常感谢,


莫里茨

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

推荐答案



" Moritz Steinberger" <莫*************** @ yahoo.de>在消息中写道

新闻:c1 ************* @ news.t-online.com ...

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

我想用一个教程来迈出第一步。我使用MS Visual c ++ 6.0和Win 98.当我尝试编译一个hello world时。程序使用
< iostream.h>库和cout<< hello world,编译器告诉我cout。是一个未声明的标识符。但它没有告诉我包括iostream.h
会导致任何问题。我在德国新闻组中读到,而不是
< iostrem.h>,只需< iostrem>必须包含在MS Visual C ++和
中,必须使用std :: cout。但是当我尝试这个时,编译器说
引用#include< iostream>:eh.h仅适用于C ++。我应该
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



怎么做?


如果您的源代码文件以.c结尾,则其编译为C。代码而不是

以你喜欢的方式工作。


#include< iostream>是适当的C ++形式。还记得cout在

命名空间std中。所以你需要std :: cout。


Jeff F


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




" Moritz斯坦伯格" <莫*************** @ yahoo.de>在消息中写道

新闻:c1 ************* @ news.t-online.com ...

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

我想用一个教程来迈出第一步。我使用MS Visual c ++ 6.0和Win 98.当我尝试编译一个hello world时。程序使用
< iostream.h>库和cout<< hello world,编译器告诉我cout。是一个未声明的标识符。但它没有告诉我包括iostream.h
会导致任何问题。我在德国新闻组中读到,而不是
< iostrem.h>,只需< iostrem>必须包含在MS Visual C ++和
中,必须使用std :: cout。但是当我尝试这个时,编译器说
引用#include< iostream>:eh.h仅适用于C ++。我该怎么办b $ b呢?
非常感谢你,莫里茨
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




确保你'' re filename被称为something.cpp。听起来好像你是调用C编译器而不是C ++编译器。


关于< iostream>的建议或者< iostream.h>适用于所有编译器。只有

< iostream>是正确的C ++。


john



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


Moritz Steinberger写道:
Moritz Steinberger wrote:

我想要使用教程迈出第一步。我使用MS Visual c ++ 6.0和Win 98.当我尝试编译一个hello world时。程序使用< iostream.h>
库和cout<< hello world,编译器告诉我cout。是一个未声明的标识符。但它没有告诉我包括iostream.h
会导致任何问题。我在德国新闻组中读到,而不是
< iostrem.h>,只需< iostrem>必须包含在MS Visual C ++和


iostream.h是一个不应该再使用的旧标题。

请按照新闻组中的建议进行操作。


另外,你可能想要一本好书来学习C ++。

" Accelerated C ++"非常适合初学者。

必须使用std :: cout。但是当我尝试这个时,编译器说
引用#include< iostream>:eh.h仅适用于C ++。我该怎么办?

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?




你的问题在这里是offtopic,因为你有问题

使用特定的编译器,而不是语言本身。


请在相应的

NG中询问编译器特定的问题,例如microsoft.public.de.vc(一个致力于VC ++的德语)

尽管如此,你的问题出现了,因为你已经命名了你的

源文件.c编译器认为你想要C语言中的程序。


所以只需将源文件重命名为.cpp就可以了。


hth


Christoph



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


这篇关于使用ms visual c ++ 6.0的iostream.h?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆