一个获取输出流对象的格式问题
B828 2003-10-25 04:25:14 假设我定义一个类:
// XXX.h
#include <iostream>
#include <string>
class XXX
{
public:
...
friend ostream & operator<<(ostream &,const XXX &); // 定义输
//出流重载
// 用来输出abc
private:
string abc;
};
我在主函数中这样调用
#include <iostream>
#include "XXX.h"
using namespace std;
void main()
{
XXX a;
cout<<hex<<a<<endl; // 希望那个字符串变量用hex方式来显示
cout<<dec<<a<<endl; // 希望那个字符串变量用dec方式来显示
....
}
请问我在 friend ostream & operator<<(ostream &,const XXX &);函数中怎么获得otream &的格式信息,根据设置hex和dec的情况来控制输出。
谢谢