Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef EMPLOYEE_HH
- #define EMPLOYEE_HH
- #include <set>
- #include <string>
- #include <iostream>
- using namespace std ;
- class Employee {
- public:
- // Constructor
- Employee(const char* name, double salary) :
- _name(name),
- _salary(salary) {
- }
- // Accessors
- const char* name() const {
- return _name.c_str() ;
- }
- double salary() const {
- return _salary ;
- }
- private:
- string _name ;
- double _salary ;
- } ;
- class Manager : public Employee {
- public:
- //Constructor
- Manager(const char* _name, double _salary):
- Employee(_name, _salary),
- _subordinates() {
- }
- // Accessors/Modifiers
- void addSubordinate(Employee& empl) {
- _subordinates.insert(empl) ; // Error: no macthing function call for .insert()
- }
- private:
- set<Employee*> _subordinates ;
- } ;
- #endif
- #include <string>
- #include <iostream>
- #include "Employee.hh"
- using namespace std ;
- int main() {
- Employee emp = ("David", 10000) ;
- Manager mgr = ("Oscar", 20000) ;
- mgr.addSubordinate(emp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement