There may be a couple of reasons for this choice.
For example, if your program compares birth date to current date you will eventually run into cases where the uint8_t
will overflow if your program is in use long enough.
Or if the person is dead, or has an invalid age you may wish to set a negative number as a form of error, -1
for not set, -2
for dead, -3
for out of range, etc.
On some platforms cout
will treat uint8_t
as a char
when printing, causing confusing output to those who do not expect it. ( @M.M pointed this out, More Info )
This approach also allows you more flexibility with the allowance of negative numbers / larger values. Basically in the general case memory is quite cheep, specially when dealing with 8 bits.
It's better to write code that has less chance of overflowing and is more flexable than to worry about packing more data into a smaller space.