[Exercise 4]

Design and implement a class "Person"

description | hints | solution | discussion
exercises after lesson "More on Classes"
list of all exercises

Now, after we just extended two existing classes in exercise 2 and 3, it is time to implement a totally new class. In our person sorting program from exercise 3, replace the struct Person by a simple class. Keep the class minimal, only implement a constructor which creates a person out of its name, first name, and birthday, access functions to read these attributes, and an operator<=() which should be defined in the same way as in the original main program. Implement this class in a separate file Person.h.

Finally, change the main program to use the new class instead of the Person struct.

Additional hints

Solution:

Additionally needed sources:

Discussion of solution (*)