Classes

struct EmployeeA       // EmployeeA is a new type
{
  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
{
  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
};

EmployeeA empA;    // variable of type EmployeeA
EmployeeB empB;    // variable of type EmployeeB
                   //   called a class object

empA.salary = 45200.0f;  // ok, can access members
empB.salary = 45200.0f;  // error, can't access members
Previous page
Next page

Back to Index
Back to Outline