#include <iostream>
#include <string>
using namespace std;

////////////////////////////////////////////////////////////////////////

class Person {
public:
  Person(const string &name="", int yearOfBirth=0);
  void setName(const string &name);
  string getName() const;
  void setYearOfBirth(int yearOfBirth);
  int getYearOfBirth() const;
  void print(ostream&) const;

private:
  string name_;
  int yearOfBirth_;
};

Person::Person(const string &name, int yearOfBirth)
  : name_(name), yearOfBirth_(yearOfBirth) {
  // leerer Rumpf
}

// alternativ: 
//
// Person::Person(const string &name, int yearOfBirth) {
//   name_ = name;
//   yearOfBirth_ = yearOfBirth;
// }

void Person::setName(const string &name) {
  name_ = name;
}

string Person::getName() const {
  return name_;
}

void Person::setYearOfBirth(int yearOfBirth) {
  yearOfBirth_ = yearOfBirth;
}

int Person::getYearOfBirth() const {
  return yearOfBirth_;
}

void Person::print(ostream &os) const {
  os << getName()
     << " " << getYearOfBirth();
}

ostream& operator<<(ostream &os, const Person &p) {
  p.print(os);
  return os;
} 

int main() {
  Person nobody;
  cout << "Person: " << nobody << endl;

  nobody.setName("Terence Hill");
  nobody.setYearOfBirth(1939);
  cout << "Person: " << nobody << endl;

  Person p("Sandy Denny", 1947);
  cout << "Person: " << p << endl;

  return 0;
}

