//parent class
#ifndef PERSON
#define PERSON
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
class Person
{
public:
//input person variable
std::istream& read(std::istream&, Person &p1);
//output person variable
std::ostream& print(std::ostream& os, const Person &p1);
//get name
std::string& get_name(Person& p);
//comparison operator
bool operator<(const Person&) const;
private:
std::string name;
std::string address;
};
#endif
#include "Person.h"
//input for address book person element
std::istream& Person::read(std::istream& in, Person &p1) {
std::cin >> p1.name;
std::cin.ignore();
std::getline(std::cin, p1.address);
return in;
}
//operator for address book person element
std::ostream& Person::print(std::ostream& os, const Person &p1) {
os << "Name: " << p1.name << "\nAddress: " << p1.address << "\n\n";
return os;
}
std::string& Person::get_name(Person& p) {
return p.name;
}
bool Person::operator<(const Person& other) const {
return name < other.name;
}