流类库11

#include<iostream>
#include<fstream>
using namespace std;
class Dog{
public:
int gdoga()
{
return a;
}
int gdogw()
{
return w;
}
void setdog(int x,int y)
{
a=x;
w=y;
}
private:
int a,w;
};
int main()
{
int v1,v2;
Dog dog1;
dog1.setdog(5,10);
ofstream
outFile("outfile.txt",ios::out);
outFile<<dog1.gdoga()<<" "<<dog1.gdogw();
outFile.close();
Dog dog2;
ifstream
inFile("outfile.txt",ios::in);
inFile>>v1;
inFile.seekg(1,ios::cur);
inFile>>v2;
dog2.setdog(v1,v2);
outFile.close();
cout<<"Weight:"<<dog2.gdoga()<<" ";
cout<<"Age:"<<dog1.gdogw();
return 0;
}

posted @   不会JAVA的小袁  阅读(9)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示