怎样将枚举类型数据存成文本文件?
nurbs 2002-12-31 03:57:09 怎样将枚举类型数据存成文本文件?
我的程序是这样的:
enum PicType{bottom, inside, outside, unengaged};
class tempfile : public CObject
{
protected:
DECLARE_SERIAL(tempfile);
int a;
short b;
long c;
float d;
double e;
BOOL f;
CString str;
PicType type;
public:
tempfile();
virtual ~tempfile();
void Save(CFile *pFile);
void Serialize(CArchive &ar);
};
tempfile::tempfile()
{
a = 10;
b = 20;
c = 30;
d = 40;
e = 50;
f = TRUE;
str = "the end!";
type = unengaged;
}
void tempfile::Save(CFile *pFile)
{
CString cs;
cs.format("\t%???\r\n", a);
pFile->Write(cs, cs.GetLength());
cs.format("\t%???\r\n", b);
pFile->Write(cs, cs.GetLength());
cs.format("\t%???\r\n", c);
pFile->Write(cs, cs.GetLength());
cs.format("\t%???\r\n", d);
pFile->Write(cs, cs.GetLength());
cs.format("\t%???\r\n", e);
pFile->Write(cs, cs.GetLength());
cs.format("\t%???\r\n", f);
pFile->Write(cs, cs.GetLength());
cs.format("\t%???\r\n", str);
pFile->Write(cs, cs.GetLength());
cs.format("\t%???\r\n", type);
pFile->Write(cs, cs.GetLength());
}
程序中???应用什么来代替,比如d,s,f或者其他的,尤其是枚举类型应怎么处理?