找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 620|回复: 5

[求助]请问标准命名空间保存在哪?

[复制链接]
发表于 2009-11-6 00:39:18 | 显示全部楼层 |阅读模式 IP:江苏扬州
总是要using namespace std;可就是不知道这个命名空间定义在哪里?
哪位朋友能够指点一下吗?
发表于 2009-11-6 00:39:19 | 显示全部楼层 IP:江苏扬州
你的意思是?
一般情况就不说了,今天查MSDN的时候也看到这个情况
// expre_reinterpret_cast_Operator.cpp
// compile with: /EHsc
#include <iostream>
// Returns a hash code based on an address
unsigned short Hash( void *p ) {
unsigned int val = reinterpret_cast<unsigned int>( p );
return ( unsigned short )( val ^ (val >> 16));
}
using namespace std;
int main() {
int a[20];
for ( int i = 0; i < 20; i++ )
cout << Hash( a + i ) << endl;
}
回复

使用道具 举报

发表于 2009-11-6 00:39:20 | 显示全部楼层 IP:江苏扬州
这是俺在MSDN上查到的:
<utility>
namespace std {
// TEMPLATE CLASSES
template<class T, class U>
struct pair;
// TEMPLATE FUNCTIONS
template<class T, class U>
pair<T, U> make_pair(const T& x, const U& y);
template<class T, class U>
bool operator==(const pair<T, U>& x, const pair<T, U>& y);
template<class T, class U>
bool operator!=(const pair<T, U>& x, const pair<T, U>& y);
template<class T, class U>
bool operator<(const pair<T, U>& x, const pair<T, U>& y);
template<class T, class U>
bool operator>(const pair<T, U>& x, const pair<T, U>& y);
template<class T, class U>
bool operator<=(const pair<T, U>& x, const pair<T, U>& y);
template<class T, class U>
bool operator>=(const pair<T, U>& x, const pair<T, U>& y);
namespace rel_ops {
template<class T>
bool operator!=(const T& x, const T& y);
template<class T>
bool operator<=(const T& x, const T& y);
template<class T>
bool operator>(const T& x, const T& y);
template<class T>
bool operator>=(const T& x, const T& y);
};
};
Include the STL standard header <utility> to define several templates of general use throughout the Standard Template Library.
Four template operators -- operator!=, operator<=, operator>, and operator>= -- define a total ordering on pairs of operands of the same type, given definitions of operator== and operator<.
If an implementation supports namespaces, these template operators are defined in the rel_ops namespace, nested within the std namespace. If you wish to use these template operators, write the declaration:
using namespace std::rel_ops;
which promotes the template operators into the current namespace.
回复

使用道具 举报

发表于 2009-11-6 00:39:21 | 显示全部楼层 IP:江苏扬州
以下是引用yuyunliuhen在2007-4-30 23:55:51的发言:

你的意思是?
一般情况就不说了,今天查MSDN的时候也看到这个情况
// expre_reinterpret_cast_Operator.cpp
// compile with: /EHsc
#include <iostream>
// Returns a hash code based on an address
unsigned short Hash( void *p ) {
unsigned int val = reinterpret_cast<unsigned int>( p );
return ( unsigned short )( val ^ (val >> 16));
}
using namespace std;
int main() {
int a[20];
for ( int i = 0; i < 20; i++ )
cout << Hash( a + i ) << endl;
}

也就是说我们自己定义的命名空间都保存在一定的文件当中,而标准命名空间保存在哪个文件当中?
回复

使用道具 举报

发表于 2009-11-6 00:39:23 | 显示全部楼层 IP:江苏扬州
namespace std定义在utility.h中呀
回复

使用道具 举报

发表于 2009-11-6 00:39:24 | 显示全部楼层 IP:江苏扬州
以下是引用weishj在2007-5-1 22:15:03的发言:
namespace std定义在utility.h中呀
我打开看怎么没有啊?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-10-1 12:10 , Processed in 0.318437 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表