如何对__int64类型重载<<和>>
如何对__int64类型重载<<和>>,以方便输入、输出?
[解决办法]
记得默认有这个类型的重载
[解决办法]
- C/C++ code
//使用vc6.0//发现//__int32 i32;//cout<<i32;//可以,利用这一点,有个简单的方法。//是否有缺点未知,仅供参考;好处是不用了解STL的底层实现#include "stdafx.h"#include <iostream>using namespace std;std::ostream& operator << (std::ostream& strm, const __int64& i){ union { __int64 a; __int32 b[2]; }; a=i; cout<<b[1]<<b[0]; return strm;};void main(){__int64 t2=0x2234567824681357;cout<<"answer is:"<<endl;cout<<hex<<t2<<endl;}
[解决办法]
- C/C++ code
stl 默认支持 #include "iostream"using namespace std;int main(){ __int64 i = 1000000000000000000; cout<<i<<endl; return 0;}