命名空间 [英] Namespaces
问题描述
以下是我的代码示例:
//头文件
#include< vector>
使用std :: vector;
命名空间启示{
//类定义等...
//班级成员是类型std :: vector
}
//源文件
#include< header_file>
命名空间启示录{
//这里使用std :: vector的东西;
}
现在我的问题是:我应该在哪里把#include< vector>和
我应该使用std :: vector ???我的命名空间之外?包括
外部和使用内?两个都在里面?
谢谢,
马丁
Here is an example of my code:
//Header file
#include <vector>
using std::vector;
namespace Revelation {
// class definitions, etc...
// class members are of type std::vector
}
//Source File
#include <header_file>
namespace Revelation {
// stuff that used std::vector here;
}
Now my question is: where should I put the #include<vector>, and where
should I put using std::vector ??? Both outside of my namespace? Include
outside and "using" inside? Both inside?
Thanks,
Martin
推荐答案
周六, 2003年9月6日01:20:47 -0400,Marcin Vorbrodt < MV ***** @ eos.ncsu.edu>写道:
On Sat, 6 Sep 2003 01:20:47 -0400, "Marcin Vorbrodt" <mv*****@eos.ncsu.edu> wrote:
这是我的代码示例:
//头文件
#include< vector>
好的。
使用std :: vector;
不要在头文件中这样做。
命名空间启示{
//类定义等...
//类成员的类型为std :: vector
}
//源文件
#include< header_file>
名称空间启示{
//在这里使用std :: vector的东西;
}
现在我的问题是:我应该把#include< vector>,
$ b放在哪里$ b确定原样。
我应该在哪里使用std :: vector ???
Here is an example of my code:
//Header file
#include <vector>
OK.
using std::vector;
Don''t do that in a header file.
namespace Revelation {
// class definitions, etc...
// class members are of type std::vector
}
//Source File
#include <header_file>
namespace Revelation {
// stuff that used std::vector here;
}
Now my question is: where should I put the #include<vector>,
OK as is.
and where should I put using std::vector ???
不在头文件。
在使用''std :: vector''不合格的代码之前。
Not in the header file.
Before the code that uses ''std::vector'' unqualified.
让我更具体......
#unclude和使用是否应该在我的命名空间内或之前?
Martin
" Alf P. Steinbach" <人*** @ start.no>在消息中写道
news:3f **************** @ News.CIS.DFN.DE ...
Let me be more specific...
Should the #unclude and using be inside my namespace or before it?
Martin
"Alf P. Steinbach" <al***@start.no> wrote in message
news:3f****************@News.CIS.DFN.DE...
On星期六,2003年9月6日01:20:47 -0400,Marcin Vorbrodt
< mv ***** @ eos.ncsu.edu>写道:
On Sat, 6 Sep 2003 01:20:47 -0400, "Marcin Vorbrodt" <mv*****@eos.ncsu.edu> wrote:
这是我的代码示例:
//头文件
#include< vector>
Here is an example of my code:
//Header file
#include <vector>
好的。
OK.
使用std :: vector;
using std::vector;
不要在头文件中这样做。< br>
Don''t do that in a header file.
命名空间启示{
//类定义等...
//类成员的类型为std :: vector
}
//源文件
#include< header_file>
命名空间启示{
//在这里使用std :: vector的东西;
}
现在我的问题是:我应该把#include< vector>,
namespace Revelation {
// class definitions, etc...
// class members are of type std::vector
}
//Source File
#include <header_file>
namespace Revelation {
// stuff that used std::vector here;
}
Now my question is: where should I put the #include<vector>,
按原样确定。
OK as is.
我应该在哪里使用std :: vector ???
and where should I put using std::vector ???
不在头文件中。
在使用''std的代码之前: :vector''不合格。
Not in the header file.
Before the code that uses ''std::vector'' unqualified.
On Sat,2003年9月6日02:00:04 -0400,Marcin Vorbro DT" < MV ***** @ eos.ncsu.edu>写道:
答案:因为它弄乱了人们通常阅读文本的顺序。
问题:为什么顶级发布这样的坏事?
答案:热门帖子。
问题:Usenet上最烦人的事情是什么?
On Sat, 6 Sep 2003 02:00:04 -0400, "Marcin Vorbrodt" <mv*****@eos.ncsu.edu> wrote:
Answer: Because it messes up the order in which people normally read text.
Question: Why is top-posting such a bad thing?
Answer: Top-posting.
Question: What is the most annoying thing on Usenet?
让我更具体一点......
#unclude和using应该在我的命名空间内还是在它之前?
Martin
Alf P. Steinbach <人*** @ start.no>在消息中写道
新闻:3f **************** @ News.CIS.DFN.DE ...
Let me be more specific...
Should the #unclude and using be inside my namespace or before it?
Martin
"Alf P. Steinbach" <al***@start.no> wrote in message
news:3f****************@News.CIS.DFN.DE...
9月6日星期六2003 01:20:47 -0400,Marcin Vorbrodt
On Sat, 6 Sep 2003 01:20:47 -0400, "Marcin Vorbrodt"
< mv ***** @ eos.ncsu.edu>写道:
<mv*****@eos.ncsu.edu> wrote:
>以下是我的代码示例:
>
> //头文件
> #include< vector>
>Here is an example of my code:
>
>//Header file
>#include <vector>
好的。
OK.
>使用std :: vector;
>using std::vector;
不要在头文件中这样做。
Don''t do that in a header file.
>命名空间启示{
> //类定义等......
> //类成员的类型为std :: vector
>}
>
>
> //源文件
> #include< header_file>
>命名空间启示录{
> //在这里使用std :: vector的东西;
>}
>
>现在我的问题是:我应该把#include< vector>,
>namespace Revelation {
> // class definitions, etc...
> // class members are of type std::vector
>}
>
>
>//Source File
>#include <header_file>
>namespace Revelation {
> // stuff that used std::vector here;
>}
>
>Now my question is: where should I put the #include<vector>,
放在哪里
好的。
OK as is.
>我应该在哪里使用std :: vector ???
> and where should I put using std::vector ???
不在头文件中。
在使用''std :: vector的代码之前''不合格。
Not in the header file.
Before the code that uses ''std::vector'' unqualified.
这篇关于命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!