Class hierarchy and polymorphismus
employee.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <string>
5 
8 class Employee
9 {
10  public:
14  explicit Employee(const std::string& name); // explicit suggested by Intel compiler for a on-element parameter list in constructor
16  virtual ~Employee();
17 
18  Employee(Employee const&) = default;
19  Employee& operator=(Employee const&) = default;
20 
21  std::string const & Get_name() const
22  {return _name;}
23 
24 
28  virtual void print(std::ostream& s) const;
29 
33  virtual float payment() const = 0; // rein virtuell
34 // {return 0.0f; } // da war die Methode nur virtuell
35 
39  int get_Counter() const {return _counter;}
40 
41  protected:
42  private:
43  std::string _name;
44  static int _counter;
45 };
46 
47 std::ostream& operator<<(std::ostream &s, const Employee& org); // Deklaration
48 
49 // --------------- new for application of STL
50 // needed for sorting of elements
51 inline bool operator<(const Employee& lhs, const Employee& rhs)
52 {
53  return lhs.payment() < rhs.payment();
54 }
Employee(const std::string &name)
Definition: employee.cpp:8
int get_Counter() const
Definition: employee.h:39
virtual ~Employee()
Definition: employee.cpp:15
virtual float payment() const =0
virtual void print(std::ostream &s) const
Definition: employee.cpp:22
std::string const & Get_name() const
Definition: employee.h:21
Employee(Employee const &)=default
Employee & operator=(Employee const &)=default
bool operator<(const Employee &lhs, const Employee &rhs)
Definition: employee.h:51
std::ostream & operator<<(std::ostream &s, const Employee &org)