The C++ Version: Part 1
private: // private members: class access only
public: // public members: anyone can access
// This is a constructor: the only way
// to create a new instance of this class
employee(char *n, int pay);
// This is a destructor: always called
// when the instance goes away
employee::employee(char *n, int pay)
year_started = current_year();
- Note that “public” members deal with the interface whereas “private” members deal with the implementation; strong division
- We enforce the fact that new employees must have a name and base pay; leave time must be 0 and year started must be now
- We enforce that memory is allocated for name when it’s created and destroyed when done