是“using namespace std”好作风? [英] is "using namespace std" good style?

查看:85
本文介绍了是“using namespace std”好作风?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的许多C ++程序都使用命名空间std来支持
;


但是Accelerated C ++ Koenig和Moo的书有很多例子

,其中库名一次包括一个,例如


使用std :: cin;

使用std :: cout;


我想知道有经验的C ++程序是否发现使用库

名称明确值得麻烦 - 这样做的好处是什么?

如此?

Many of my C++ programs have the line

using namespace std;

but the "Accelerated C++" book of Koenig and Moo has many examples
where the library names are included one at a time, for example

using std::cin;
using std::cout;

I wonder if experienced C++ programs have found that ''using'' library
names explicitly is worth the bother -- what is the advantage of doing
so?

推荐答案

2004年5月25日09:02:38 -0700, be*******@aol.com 写道:
On 25 May 2004 09:02:38 -0700, be*******@aol.com wrote:
我的许多C ++程序都使用命名空间std;

但是Accelerated C ++ Koenig和Moo的书有很多例子,其中库名一次包括一个,例如

使用std :: cin;
使用std :: cout;

我想知道有经验的C ++程序是否发现明确使用库名称是值得的 - 这样做有什么好处?
Many of my C++ programs have the line

using namespace std;

but the "Accelerated C++" book of Koenig and Moo has many examples
where the library names are included one at a time, for example

using std::cin;
using std::cout;

I wonder if experienced C++ programs have found that ''using'' library
names explicitly is worth the bother -- what is the advantage of doing
so?




刚刚发现这个,显然是来自这个群体,但没有注明日期:

http://www.janko.at/Humor/Computerwe...pace%20std.htm


我是其中一个有罪的人。没有树立良好榜样的人;我的测试

模板put" using namespace std;"在包括

< iostream>之后右上角。这几乎总是适合我的目的,但由于大多数

我的积蓄没有类型std ::在cin,cout和endl之前,我可能只需要使用

模板文件中的声明来替换使用这三个指令的
...

-leor


-

Leor Zolman --- BD软件--- www.bdsoft.com

C / C ++,Java,Perl和Unix的现场培训

C ++用户:下载BD Software的免费STL错误消息解密器:
www.bdsoft.com/tools/stlfilt.html



Just found this, evidently from this group, but undated:

http://www.janko.at/Humor/Computerwe...pace%20std.htm

I''ve been one of the "guilty" ones not setting a good example; my testing
template puts "using namespace std;" up top right after including
<iostream>. This is almost always fine for my purposes, but since most of
my savings is not having type "std::" in front of cin, cout and endl, I may
as well just replace the directive with those three using declarations in
the template file...
-leor

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: download BD Software''s free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html


Leor Zolman写道:
Leor Zolman wrote:

2004年5月25日09:02:38 -0700, be*******@aol.com 写道:

On 25 May 2004 09:02:38 -0700, be*******@aol.com wrote:
我的许多C ++程序都使用命名空间std;

但是Accelerated C ++ ; Koenig和Moo的书有很多例子,其中库名一次包括一个,例如

使用std :: cin;
使用std :: cout;

我想知道有经验的C ++程序是否发现明确使用库名称是值得的 - 这样做有什么好处?
Many of my C++ programs have the line

using namespace std;

but the "Accelerated C++" book of Koenig and Moo has many examples
where the library names are included one at a time, for example

using std::cin;
using std::cout;

I wonder if experienced C++ programs have found that ''using'' library
names explicitly is worth the bother -- what is the advantage of doing
so?



刚刚发现这个,显然是来自这个群体,但没有注明日期:

http://www.janko.at/Humor/Computerwe...pace%20std.htm

我他是有罪之一。没有树立良好榜样的人;我的测试
模板put" using namespace std;"在包括
< iostream>之后右上方。这几乎总是适合我的目的,但由于我的大部分储蓄都没有类型std ::在cin,cout和endl之前,我也可以使用
模板文件中的声明来替换那三个指令......
-leor



Just found this, evidently from this group, but undated:

http://www.janko.at/Humor/Computerwe...pace%20std.htm

I''ve been one of the "guilty" ones not setting a good example; my testing
template puts "using namespace std;" up top right after including
<iostream>. This is almost always fine for my purposes, but since most of
my savings is not having type "std::" in front of cin, cout and endl, I may
as well just replace the directive with those three using declarations in
the template file...
-leor



我还在试图找出使用''命名空间'的任何好处 -

个人,我希望它不属于语言。



I''m still trying to figure out any benefit at all for using ''namespace'' --
personally, I wish it weren''t part of the language.


2004年5月25日星期二12:12:50 -0700,Julie< ju *** @ nospam.com>写道:
On Tue, 25 May 2004 12:12:50 -0700, Julie <ju***@nospam.com> wrote:
Leor Zolman写道:
Leor Zolman wrote:

2004年5月25日09:02:38 -0700,是******* @ aol.com 写道:

On 25 May 2004 09:02:38 -0700, be*******@aol.com wrote:
>我的许多C ++程序使用命名空间std;
>
>然后使用加速C ++行。 Koenig和Moo的书有很多例子
>其中库名一次只包含一个,例如
>
>使用std :: cin;
> ;使用std :: cout;
>
>我想知道经验丰富的C ++程序是否发现明确使用库
>名称是值得的 - 这是什么做
>这样做的好处?
>Many of my C++ programs have the line
>
>using namespace std;
>
>but the "Accelerated C++" book of Koenig and Moo has many examples
>where the library names are included one at a time, for example
>
>using std::cin;
>using std::cout;
>
>I wonder if experienced C++ programs have found that ''using'' library
>names explicitly is worth the bother -- what is the advantage of doing
>so?



刚刚发现这一点,显然是来自这个群体,但未注明日期:

http://www.janko.at/Humor/Computerwe...pace% 20std.htm

我是其中一个有罪的人没有树立良好榜样的人;我的测试
模板put" using namespace std;"在包括
< iostream>之后右上方。这几乎总是适合我的目的,但由于我的大部分储蓄都没有类型std ::在cin,cout和endl之前,我也可以使用
模板文件中的声明来替换那三个指令......
-leor



Just found this, evidently from this group, but undated:

http://www.janko.at/Humor/Computerwe...pace%20std.htm

I''ve been one of the "guilty" ones not setting a good example; my testing
template puts "using namespace std;" up top right after including
<iostream>. This is almost always fine for my purposes, but since most of
my savings is not having type "std::" in front of cin, cout and endl, I may
as well just replace the directive with those three using declarations in
the template file...
-leor


我仍然试图找出使用''命名空间'的任何好处 -
我个人希望它不是语言的一部分。



I''m still trying to figure out any benefit at all for using ''namespace'' --
personally, I wish it weren''t part of the language.




如果我最终没有发布大部分的小测试程序我会在这里玩b $ b,我会继续使用指示顶部简单地

减少我的击键次数。可以将其视为符合人体工程学的。语言功能

抛弃代码;-)

-leor

-

Leor Zolman - - BD软件--- www.bdsoft.com

开 - C / C ++,Java,Perl和Unix中的现场培训

C ++用户:下载BD Software的免费STL错误消息解密器:
www.bdsoft.com/tools/stlfilt.html


这篇关于是“using namespace std”好作风?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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