Access Specifiers

The previous example is equivalent to this:
struct EmployeeA         // EmployeeA is a new type
{
  public:                // members are visible
    char firstName[10];  // first name is a char array
    char lastName[12];   // last name is char array
    float salary;        // yearly pay is float
    int years;           // years of service
};

class EmployeeB          // EmployeeB is a new type
{
  private:               // members are not visible
    char firstName[10];  // first name is a char array
    char lastName[12];   // last name is char array
    float salary;        // yearly pay is float
    int years;           // years of service
};
The access specifiers are redundant. However, you should always provide an access specifier for classes. You will typically not provide any for structures. This means that structure members will always be accessible.

Previous page
Next page

Back to Index
Back to Outline