function in Composite design pattern

I have to do a function, addSubordinate. The specification of how to do the function is below:
The addSubordinate method accepts a Worker object and assigns it to the supervisors array.

In the Workers class is the constructor, which accepts three string arguments, and a showDetails() function, which just shows details about worker e.g name, phone, email

I did the following code for the addSubordinate function, im not sure if its right though;

1
2
3
4
5
void addSubordinate(const Worker &object)
{
        //trying to assign Worker(class) object to supervisors array
	Worker supervisor[4] = object;
}
It is incorrect syntax

Worker supervisor[4] = object;

First of all you create a local array while according to your assignment you have to add a Worker object to the supervisors array. So class supervisor (or what is its name) should have such an array.
Last edited on
Topic archived. No new replies allowed.