You can't have an STL container of references to objects. That is,
std::list<Employee&> e;
doesn't have a chance to compile. This is attributed to the fact that STL containers require that their elements are Erasable [Note: Before C++11 the requirements were to be CopyAssignable and CopyConstructible]. Unfortunately, references are not.
Also since you have the C++11 tag, you should be aware that use of raw pointers is highly discouraged in favour of smart pointers like std::unique_ptr
and std::shared_ptr
. Thus, is better to avoid this:
std::list<Employee*> e;
in favour of something like:
std::list<std::shared_ptr<Employee>> e;