daka

#include<bits/stdc++.h>

using namespace std;

class Dog
{
public: 
    int age;
    double weight;
    Dog(int a, double b): age(a) , weight(b) {
    }
    Dog() {
    }
 } ;
 
 int main()
 {
     Dog dog1(10, 5);
     Dog dog2;
     ofstream out1("dog.txt", ios::out);
     out1 << dog1.age << " " << dog1.weight ;
     out1.close();
     
     ifstream in1("dog.txt", ios::in);
     in1 >> dog2.age >> dog2.weight;
     in1.close();
     
     cout << dog2.age << " " << dog2.weight;
 }

 

posted @ 2023-05-19 22:49  kxzzow  阅读(18)  评论(0)    收藏  举报