Hi
I am a beginner of C++.
Now I am going to write a inheritance program.
The following is the introduction of my program.
a. Implement the class "Employ" that have:
¡P protected data members name and salary which store the name of Employs and monthly salary;
¡P getName() retrieves the name of employs.
¡P calculateSalary() retrieves the salary.
b. Implement the Derive subclasses "Full-time" and ¡§Part-time¡¨. The calculateSalary() will calculate salary based on the following rules. printAll() function prints all information.
¡P For the Full-time employee, data member year stores the number of year the employ worked. If the year is > 15 years, then the salary would be increased by 20%, if the year is <= 15 years, then the salary would be increased by 10%.
¡P For the part-time employ, data member hourlyPay stores the hourly salary and hours store the number of hour the employ worked. The formula for calculateSalary() is ¡§salary =base-salary +hours * hourlyPay¡¨.
==================================================
I want my program include 7 files.
1.main.cpp (I have attached it)
2.employ.cpp
3.employ.h
4.fulltime.cpp
5.fulltime.h
6.parttime.cpp
7.parttime.h
Employ.h as following
=====================
#ifndef Employ_H
#define Employ_H
class Employ
{
public:
char* getName();
float calculateSalary();
void printAll();
protected:
char* Name;
float salary;
};
#endif
=================================
And I am writing the Employ.cpp.
But I don't know how to write the function of "getName", as it is use char pointer with it.
Can anyone help me solve this question?
Thanks a lot~



LinkBack URL
About LinkBacks


