Examples of Different Initializers

This example demonstrates the use of different constructors. Both objects, clerk1 and clerk2, ultimately contain the same values, although the values were assigned differently.
#include "Employee.h"     // Employee class

void main(void)
{
  Employee clerk1("Jane", "Doe", 50000.0f, 10);  
  Employee clerk2("Jane", "Doe");

  clerk2.display();

  clerk2.setSalary(50000.0f);
  clerk2.setYears(10);

  clerk1.display();
  clerk2.display();
}
Output:

  Name: Doe, Jane 
Salary: $0.00
 Years: 0

  Name: Doe, Jane 
Salary: $50000.00
 Years: 10

Name: Doe, Jane 
Salary: $50000.00
 Years: 10
Previous page
Next page

Back to Index
Back to Outline