< fstream.h> ,不需要< iostream.h>? [英] <fstream.h> , no need for <iostream.h>?

查看:78
本文介绍了< fstream.h> ,不需要< iostream.h>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经读过包含< fstream.h>包含

< iostream.h>不必要的。


这是正确的吗?


Charles L

解决方案

" Charles L" < TJ *** @ dodo.com.au>在消息中写道

新闻:40 ****** @ news.comindico.com.au ...

我已经读过包含< fstream。 h取代;包含
< iostream.h>这是正确的吗?




首先,不要使用< fstream.h>和< iostream.h>。使用< fstream>和

< iostream>相反。


至于你的问题:我不知道这种行为是否是标准的定义,

但至少在我的系统上(VC7.1) )包括< fstream>没有包含< iostream>的
不必要。所以答案是肯定的。


-

不可原谅


Unforgiven写道:

" Charles L" < TJ *** @ dodo.com.au>在消息中写道
新闻:40 ****** @ news.comindico.com.au ...

我已经读过包含< fstream。 h取代;包含
< iostream.h>这是正确的吗?



首先,不要使用< fstream.h>和< iostream.h>。使用< fstream>和
< iostream>对于你的问题:我不知道这个行为是否是标准的定义,但至少在我的系统上(VC7.1),包括< fstream>没有包含< iostream>不必要。所以答案是否定的。




标准要求在不同的

标题中声明不同的部分。要使用某个元素(类,模板,对象),需要

来包含相应的标题。实际上,这应该是一个简单的规则。

。你需要''cout''或'cerr''?使用< iostream>。你需要'b $ b'需要''字符串''?使用< string>。您需要''排序'',使用< algorithm>。等等。
一个人不应该关心自己(无论是平台或编译器 -

依赖)标准标题之间的交叉引用,即使有

a其中一些之间的逻辑连接可能暗示这样的交叉引用(或将一个包含在另一个中)。


Victor


在文章< 2k ************ @ uni-berlin.de>中,Unforgiven写道:

Charles L < TJ *** @ dodo.com.au>在消息中写道
新闻:40 ****** @ news.comindico.com.au ...

我已经读过包含< fstream.h>包含
< iostream.h>这是不正确的?


首先,不要使用< fstream.h>和< iostream.h>。使用< fstream>和
< iostream>对于你的问题:我不知道这种行为是否是标准定义的,
但至少在我的系统上(VC7.1)包括< fstream>没有包含< iostream>不必要。所以答案是否定的。



我正在上C ++课,他们使用< iostream>而不是

< iostream.h>在示例中。


使用其中一个的原因是什么。我知道如果

你使用.h你不必使用''使用std :: xxxxxx''语句。


I have read that the inclusion of <fstream.h> makes the inclusion of
<iostream.h> unnecessary.

Is this correct?

Charles L

解决方案

"Charles L" <tj***@dodo.com.au> wrote in message
news:40******@news.comindico.com.au...

I have read that the inclusion of <fstream.h> makes the inclusion of
<iostream.h> unnecessary.

Is this correct?



First of all, don''t use <fstream.h> and <iostream.h>. Use <fstream> and
<iostream> instead.

As for your question: I don''t know if that behaviour is standard defined,
but on my system at least (VC7.1) including <fstream> does not make
inclusion of <iostream> unnecessary. So the answer is no.

--
Unforgiven


Unforgiven wrote:

"Charles L" <tj***@dodo.com.au> wrote in message
news:40******@news.comindico.com.au...

I have read that the inclusion of <fstream.h> makes the inclusion of
<iostream.h> unnecessary.

Is this correct?


First of all, don''t use <fstream.h> and <iostream.h>. Use <fstream> and
<iostream> instead.

As for your question: I don''t know if that behaviour is standard
defined, but on my system at least (VC7.1) including <fstream> does not
make inclusion of <iostream> unnecessary. So the answer is no.



The Standard mandates that different pieces are declared in different
headers. To use a certain element (class, template, object) one need
to include the corresponding header. It should be a simple rule to
follow, actually. You need ''cout'' or ''cerr''? Use <iostream>. You
need ''string''? Use <string>. You need ''sort'', use <algorithm>. Etc.

One should never concern oneself with (whether platform- or compiler-
dependent) cross-references between standard headers, even if there is
a logical connection between some of them which might suggest such
cross-reference (or inclusion of one into the other).

Victor


In article <2k************@uni-berlin.de>, Unforgiven wrote:

"Charles L" <tj***@dodo.com.au> wrote in message
news:40******@news.comindico.com.au...

I have read that the inclusion of <fstream.h> makes the inclusion of
<iostream.h> unnecessary.

Is this correct?



First of all, don''t use <fstream.h> and <iostream.h>. Use <fstream> and
<iostream> instead.

As for your question: I don''t know if that behaviour is standard defined,
but on my system at least (VC7.1) including <fstream> does not make
inclusion of <iostream> unnecessary. So the answer is no.


I''m taking a class in C++ and they use <iostream> rather than
<iostream.h> in the examples.

What is the reason for using one over the other. I know that if
you use the .h you don''t have to use ''using std::xxxxxx'' statements.


这篇关于&LT; fstream.h&GT; ,不需要&lt; iostream.h&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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