I’m simulating inheritance in C, but not sure the exact way to go. I created 2 structs, Employee and Director, where Director is supposed to ‘inherit’ from Employee. How do I create an array that will be able to hold both regular Employees and Directors? This did not work:
Employee workers[3]
Below is my code for the Director struct:
typedef struct {
Employee employee;
int bonus;
} Director;
Make an
unionthat can contain either Directors or Employees, and a flag stating which part of theunionyou’re using. Then declare an array of thatuniontype.