I might be going about this wrong way. I'm being asked to create an array of objects of a particular class. That class, however, has two derived classes.
class Employee {
// Some stuff here about the backbone of the Employee class
}
class Salary: public Employee {
// Manipulation for Salary employee
}
class Hourly: public Employee {
// Manipulation for hourly Employee
}
// Main Program
int main (int argc, char**argv) {
Employee data[100]; // Creates an array of Employee objects
while (employeecount > 100 || employeecount < 1) {
cout << "How many employees? ";
cin >> employeecount;
}
for(int x = 0; x <= employeecount; x++) {
while (status != "S" || status != "s"|| status != "H" || status != "h") {
cout << "Employee Wage Class (enter H for hourly or S for Salary)";
cin >> status;
}
if (status == "S" || status == "s") { // Salaried Employee
new
} else { // We valid for hourly or salary, so if its not Salaried it's an hourly
}
}
return 0;
}
The question I want to ask is, can the base class call on the derived class methods? For example, if I created a method for the Salary class named getgross
: Can I invoke a method like this: Employee.getgross()
? If not how can I invoke a subclass method?