哪位朋友能够指点一下吗?
哪位朋友能够指点一下吗?
你的意思是?
一般情况就不说了,今天查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;
}
这是俺在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.
你的意思是?
一般情况就不说了,今天查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;
}
也就是说我们自己定义的命名空间都保存在一定的文件当中,而标准命名空间保存在哪个文件当中?
在VC下的include文件夹下吧,
就版本不是用#include<iostream.h>么,新版本应该还旧版本兼容的,iostream.h,iostream。。。都在那个文件夹下
我打开看怎么没有啊?