Ex8.* feedback: syntactic sugar
This commit is contained in:
parent
815e771d7d
commit
6d63474276
3 changed files with 7 additions and 7 deletions
|
@ -36,7 +36,7 @@ public:
|
||||||
private:
|
private:
|
||||||
string _name ;
|
string _name ;
|
||||||
double _salary ;
|
double _salary ;
|
||||||
set<Employee*> _subordinates ;// subordinates is an unordered collection so set is usefull enough
|
set<Employee*> _subordinates ;// subordinates is an unordered collection of unique people so set is usefull enough
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,15 @@ void populate_directory( set<Employee*>& directory ) {
|
||||||
Manager* jo = new Manager("Jo", 5);
|
Manager* jo = new Manager("Jo", 5);
|
||||||
Manager* frank = new Manager("Frank", 6);
|
Manager* frank = new Manager("Frank", 6);
|
||||||
|
|
||||||
(*stan).addSubordinate( *wouter );
|
stan->addSubordinate( *wouter );
|
||||||
(*stan).addSubordinate( *ivo );
|
stan->addSubordinate( *ivo );
|
||||||
|
|
||||||
directory.insert( stan );
|
directory.insert( stan );
|
||||||
directory.insert( wouter );
|
directory.insert( wouter );
|
||||||
|
|
||||||
// This does not give a problem because stan is also of type Employee
|
// This does not give a problem because stan is also of type Employee
|
||||||
(*frank).addSubordinate( *stan );
|
frank->addSubordinate( *stan );
|
||||||
(*frank).addSubordinate( *jo );
|
frank->addSubordinate( *jo );
|
||||||
|
|
||||||
directory.insert( wouter );
|
directory.insert( wouter );
|
||||||
directory.insert( ivo );
|
directory.insert( ivo );
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Circle: public Shape {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructor, destructor
|
// Constructor, destructor
|
||||||
Circle(int radius) : _radius(radius) {} ;
|
Circle( double radius ) : _radius(radius) {} ;
|
||||||
virtual ~Circle() {} ;
|
virtual ~Circle() {} ;
|
||||||
|
|
||||||
// Implementation of abstract interface
|
// Implementation of abstract interface
|
||||||
|
@ -18,6 +18,6 @@ public:
|
||||||
virtual const char* shapeName() const { return "Circle"; }
|
virtual const char* shapeName() const { return "Circle"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _radius ;
|
double _radius ;
|
||||||
} ;
|
} ;
|
||||||
#endif
|
#endif
|
||||||
|
|
Reference in a new issue