Pieter
2003-12-23 15:21:43 UTC
Hello,
//I have the following situation:
//baseclass : Employee
class Employee{
private:
string name;
public :
Employee(string);
void SetName(string);
virtual double Earnings();
//********
derived classes: Manager , Salesman
//a Manager gets paid hourly ( a constant Wage),
//a Salesman gets a fixed wage + a Commission
class Manager : public Employee {
private:
int hours;
static double wage;
public:
Manager(string);
void getHours(int); // <-----
virtual double Earnings();
/*PROBLEM:
All the managers and salesmen are stored in a STL map
map<int,Employee> ieMap; in an other class.
When I iterate this map, how can ik call getHours(int) from Manager
(supposed the iterator points to a Manager object,
or is it the whole "point" that the objects Manager and Salesman are stored
as an Employee???? I hope not..).
I tried RTTI, didn't work (probably my fault, but hey, I couldn't do it)
Is there a possibility with Polymorphism??? (and cleaner..)
Hints, tips??
kind regards,
Pieter
ps: sorry for my bad "inglisch";)
*/
//I have the following situation:
//baseclass : Employee
class Employee{
private:
string name;
public :
Employee(string);
void SetName(string);
virtual double Earnings();
//********
derived classes: Manager , Salesman
//a Manager gets paid hourly ( a constant Wage),
//a Salesman gets a fixed wage + a Commission
class Manager : public Employee {
private:
int hours;
static double wage;
public:
Manager(string);
void getHours(int); // <-----
virtual double Earnings();
/*PROBLEM:
All the managers and salesmen are stored in a STL map
map<int,Employee> ieMap; in an other class.
When I iterate this map, how can ik call getHours(int) from Manager
(supposed the iterator points to a Manager object,
or is it the whole "point" that the objects Manager and Salesman are stored
as an Employee???? I hope not..).
I tried RTTI, didn't work (probably my fault, but hey, I couldn't do it)
Is there a possibility with Polymorphism??? (and cleaner..)
Hints, tips??
kind regards,
Pieter
ps: sorry for my bad "inglisch";)
*/