Exercise: Simple Method (Users Age By n Years)

Description

Objects of type class User are initialized once in their lifetime,

User joerg("Joerg", "Faschingbauer", 55);

Currently, there is no way to celebrate birthdays, for example. User joerg remains 55 years old, indefinitely. While this is not a bad idea in general, lets implement a way to let users age. Like so,

#include "user.h"
#include <iostream>
#include <cassert>

using namespace std;



int main()
{
    User joerg("Joerg Trittsicher", "Faschingbauer", 55);

    joerg.age_by_n_years(10);
    assert(joerg.age == 65);

    return 0;
}

Essentially: add to class User a method, void age_by_n_years(unsigned int);