The Class Implementation

The code that implements the class is placed in a C++ file called Employee.cpp (.C, .cxx):
// the implementation for Employee

#include <iostream.h>   // cout
#include <iomanip.h>    // setprecision
#include <string.h>     // strcpy()
#include "employee.h"   // for Employee class

void Employee::setName(char first[], char last[])
{
  strcpy(firstName, first);
  strcpy(lastName, last);
}

void Employee::setSalary(float newSalary)
{
  salary = newSalary;
}

void Employee::setYears(int numYears)
{
  years = numYears;
}

void Employee::display(void) const
{
  cout << "  Name: " << lastName;
  cout << ", " << firstName << endl;
  cout << setprecision(2);
  cout.setf(ios::fixed | ios::showpoint);
  cout << "Salary: $" << salary << endl;
  cout << " Years: " << years << endl << endl;
}
Previous page
Next page

Back to Index
Back to Outline