I have an assignment that deals with inheritance.
I have an Employee () base class that inherits from Manager () and Intern ().
My instructor gave us the following instructions:
In main (), declare an array of pointers to personnel and initialize them with the following entries:
Manager("IT", 100, "MF1", "ML1")
Manager("HR", 50, "MF2", "ML2")
Intern("SIUE", 0, "IF1", "IL1")
Intern("SLU", 0, "IF2", "IL2")
Then I need to scroll and display the array. The result, which he provides as an example, shows that the Manager () and Intern () toString () methods should have been called because there was some information related to the child classes. However, when accessing the array, im getting pointers to employees, not pointers to a child. I added a screenshot that he provided.

I am not sure how I should do this.
:
Employee * staff = new Employee[4];
Manager(), . -, :
staff[0] = new Manager("IT", 100, "MF1", "ML1");
, - - ( ?):
Employee * e = new Manager("IT", 100, "MF1", "ML1");
staff[0] = *e;
, , , :
cout << staff[0].toString();
Employee() toString(), .
Employee() Manager() , :
class Employee{
private:
int eid;
string firstName;
string lastName;
public:
Employee();
Employee(int eid, string fname, string lname);
void setEID(int eid);
void setFirstName(string fname);
void setLastName(string lname);
int getEID();
string getFirstName();
string getLastName();
virtual string toString();
};
class Manager : public Employee, IPayable{
private:
string department;
public:
Manager();
Manager(string dept, int eid, string fname, string lname);
double pay();
void setDepartment(string d);
string getDepartment();
string toString();
};
, 2 toString(), Employee toString(), Manager() toString():
string Employee::toString(){
return "{eid = " + std::to_string(getEID()) + ", firstName = " + getFirstName() + ", lastName = " + getLastName() + "}";
}
string Manager::toString(){
return "Manager{" + Employee::toString() + ", department = " + getDepartment() + ", salary = " + std::to_string(pay()) +"}";
}