| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1044 人关注过本帖
标题:[求助]请问标准命名空间保存在哪?
只看楼主 加入收藏
华龙
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-4-3
收藏
 问题点数:0 回复次数:6 
[求助]请问标准命名空间保存在哪?
总是要using namespace std;可就是不知道这个命名空间定义在哪里?
哪位朋友能够指点一下吗?
搜索更多相关主题的帖子: 空间 保存 定义 std 
2007-04-30 18:58
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 

你的意思是?
一般情况就不说了,今天查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;
}


Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-04-30 23:55
weishj
Rank: 1
等 级:新手上路
威 望:2
帖 子:141
专家分:0
注 册:2007-4-22
收藏
得分:0 

这是俺在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.


If you shed tears when you miss the sun, you also miss the stars.
2007-05-01 13:07
华龙
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-4-3
收藏
得分:0 
以下是引用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;
}

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

2007-05-01 20:10
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 

在VC下的include文件夹下吧,
就版本不是用#include<iostream.h>么,新版本应该还旧版本兼容的,iostream.h,iostream。。。都在那个文件夹下


Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-05-01 21:37
weishj
Rank: 1
等 级:新手上路
威 望:2
帖 子:141
专家分:0
注 册:2007-4-22
收藏
得分:0 
namespace std定义在utility.h中呀

If you shed tears when you miss the sun, you also miss the stars.
2007-05-01 22:15
华龙
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-4-3
收藏
得分:0 
以下是引用weishj在2007-5-1 22:15:03的发言:
namespace std定义在utility.h中呀

我打开看怎么没有啊?

2007-05-02 13:25
快速回复:[求助]请问标准命名空间保存在哪?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014586 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved