I'm really stuck on this Assignment and I need to find a solution ASAP before I get too far behind. Basicly, we're fuddling with inheritence and I've created 3 child classes from a parent 'Employee'. Each is a different type of employee. Right now, what I have is
Manager m ("John","Doe",12,25,1950,2,14,1999, 3500, 1, "Accounting");
Salesworker s ("John","Doe",12,25,1950,2,14,1999, 3, 4, 2, 9, 1);
Peiceworker p ("John","Doe",12,25,1950,2,14,1999, 2, 2, 1, 1, 0);
Hourly h ("John","Doe",12,25,1950,2,14,1999, 44);
*teacher insists on ugly constructor overrides
what I would LIKE is something like this!
Manager* m = new Manager[3];
Salesworker* s = new Salesworker[3];
Peiceworker* p = new Peiceworker[3];
Hourly* h = new Hourly[3];
Where I custom initialize them later on for aesthetic purposes.
In either case, I'm really strapped for a menu in the console. My plan is to have the user choose the type of employee that they want to work with so that I can know what array they want to use, and then use that pointer to print a list of names and then the user can choose what Employee they want to work with. I find myself writing 4 different functions that roughly do the same thing, each take a pointer of one type, and use that pointer to then print the names, get an array position, and then point to the array, and then use my << or >> overload operators. I'd much rather find a way to genericly reference object array and position.
something like
Manager* m = new Manager[3];
Salesworker* s = new Salesworker[3];
Peiceworker* p = new Peiceworker[3];
Hourly* h = new Hourly[3];
igaPtr = ChooseArray( *m, *s, *p, *h);
printNames( *igaPtr)
cout << igaPtr[1];
Where igaPtr is a ptr that the user chose and now we're using and we don't have to explicitly call the * to object. I'm not sure if this is possible, but my class is online and my teacher lacks some serious communication skills. Any advice you can give, I would appreciate it! Thank you!