#include<bits/stdc++.h>
using namespace std;
class Dog
{
private:
int weight,age;
public:
Dog(int w,int a):weight(w),age(a)
{
}
int getw()
{
return weight;
}
int geta()
{
return age;
}
};
int main()
{
Dog dog3(5,10);
fstream out1;
out1.open("dog3.txt",ios::binary|ios::out);
out1<<"体重:"<<dog3.getw()<<endl<<"年龄:"<<dog3.geta()<<endl;
fstream in,out2;
in.open("dog3.txt",ios::binary|ios::in);.
out2.open("dog4.txt",ios::binary|ios::out);
out2<<"dog4=dog3"<<endl;
char ch;
while(!in.eof())
{
in.get(ch);
out2.put(ch);
}
return 0;
}
标签:文件,out2,int,ios,Dog,dog2,dog1 From: https://www.cnblogs.com/wwj1/p/17406561.html