home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
SAMPLES
/
BROWSER
/
PAYFUNC.H
< prev
next >
Wrap
Text File
|
1993-04-30
|
3KB
|
117 lines
/* @(#)27 1.3 src/samples/payfunc.h, samples, brs110, 930429 92/11/20 22:04:20 */
/*********************************************
*** payfunc.h -- functions for payroll.cpp ***
*********************************************/
// Constructor definition for class manager.
employee::employee(char * n, int id)
{
name = n; // Initializing
employee_id = id;
};
// Constructor definition for class manager.
// Note different way to initialize.
manager::manager(char *n, int id, double sal)
: employee(n, id), salary(sal){}
// Definition of the pay function for class manager.
double manager::pay()
{
return salary/12 ;
}
// Definition of the print function for class manager.
void manager::print()
{
cout << name << " with employee number "
<< employee_id << " makes " << salary
<< " per year.\n"
<< name << " made " << pay()
<< " dollars this month.\n\n";
}
// Constructor definition for class regular_emp.
regular_emp::regular_emp(char *n, int id,
double wg, double hrs)
: employee(n, id)
{
wage = wg;
hours = hrs;
}
// Definition of pay function for class regular_emp.
double regular_emp::pay()
{
return wage*hours;
}
// Definition of the print function for class regular_emp.
void regular_emp::print()
{
cout << name << " with employee number "
<< employee_id << " makes " << wage
<< " dollars per hour\n"
<< " and worked " << hours << " hours this month. \n"
<< name <<" made " << pay()
<< " dollars this month.\n\n";
}
// Functions for class sales_person
// Constructor definition for class sales_person.
sales_person::sales_person(char *n, int id,
double comm, double nts)
:employee(n, id), commission(comm), units(nts){}
// Definition of pay function for class sales_person.
double sales_person::pay()
{
return (commission*units);
}
// Definition of the print function for class sales_person.
void sales_person::print()
{
cout << name << " with employee number "
<< employee_id << " works for a straight commission of "
<< commission << " dollars per unit sold and sold "
<< units << " units this month.\n"
<< name <<" made " << pay()
<< " dollars this month.\n\n";
}
// Functions for class sales_mgr.
// Constructor definition for class sales_mgr.
sales_mgr::sales_mgr(char *n, int id,
double sal, double comm, double nts)
:manager(n, id, sal),
sales_person(n, id, comm, nts)
{ name = n;
employee_id = id;
salary = sal;
commission = comm;
units = nts;
}
// Definition of pay function for class sales_mgr.
double sales_mgr::pay()
{ return (manager::pay() + sales_person::pay());}
// Definition of the print function for class sales_mgr.
void sales_mgr::print()
{
cout << name << " with employee number "
<< employee_id << " makes " << salary
<< " per year and earns a commission of "
<< commission << " dollars per unit sold.\n"
<< name << " was responsible for sales of "
<< units << " units this month.\n"
<< name <<" made " << pay()
<< " dollars this month.\n\n";
}
/**** End of comp_func.h (function definitions). ****/