#include <iostream>#include <fstream>#include <string>using namespace std;class Person {public: Person() : name(""), surname(""), age(0), height(0), weight(0), phone("") {} friend istream &operator>> (istream &in, Person &p); friend ostream &operator<< ( ostream &out, Person &p );protected: string name; string surname; int age; int height; int weight; string phone;};istream &operator>> (istream &in, Person &p) { in >> p.name >> p.surname >> p.age >> p.height >> p.weight >> p.phone; return in;}ostream &operator<< ( ostream &out, Person &p ) { return out << p.name << "\n"<< p.surname << "\n"<< p.age << "\n"<< p.height << "\n"<< p.weight<< "\n"<< p.phone;}int main() { Person p; ifstream in("person.txt"); in >> p; cout << p << endl; in.close(); return 0;}
Comments