#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; }
标签:daka,weight,int,age,Dog,dog2 From: https://www.cnblogs.com/kongxiangzeng/p/17416517.html