class data
{
private:
int MyData;
public:
data(int n=0;){MyData=n;}
void SetData(int n){MyData=n;}
void OutPut()
{
fstream temptfile;
temptfile.open("data.txt",ios::out);
temptfile<<MyData<<"\n;
temptfile.close();temptfile.clear();
}
void Input()
{
fstream temptfile;char tmpchr[]="";//定义用于读取信息的字符串
temptfile.open("data.txt",ios::in);
temptfile.getline(tmpchr,10,'\n');
MyData=atoi(tmpchr); //把读出的字符串转成自己需要的类型
temptfile.close();temptfile.clear();
}
}