The C++ Version: Part 2
class employee *c_employees[MAX_EMPLOYEES];
employees(void) { num_employees = 0; }
int add_employee(char *name, int pay);
int employees::add_employee(char *name, int pay)
if (num_employees >= MAX_EMPLOYEES) {
c_employees[num_employees++] =
- num_employees guaranteed to be initialized
- Bounds checking inherent to the class employees
- Note use of “new” that can pass args to the constructor
- No one can touch our private data
- We could write a destructor that deallocates all allocated memory