On line 19, you're along the right lines - you're specifying a base class (i.e.
Employee) constructor in the initialisation list of the derived class (
ProductionWorker) constructor:
18 19
|
// Constructor
ProductionWorker() : Employee(e);
|
However, there are a few things wrong with it. Firstly, there are no arguments to the
ProductionWorker constructor, which means you're declaring a default constructor. But you've already declared a default constructor at line 17 - you can't have two different constructors with the same signature.
If the purpose is to have a
ProductionWorker constructor that passes data through to it's base class constructor, then you want to have the
ProductionWorker constructor take that data as parameters, so it can pass them through to the
Employee constructor.
Secondly, initialisation lists are used in the definition of a method, not the declaration.
Thirdly, look at that initialisation list. What is
e in this context? There's no definition of anything called
e, and nor is there any constructor defined for
Employee that only takes a single argument.
Your initialisation list should invoke the base class constructor that you want it to invoke. The arguments to the
Employee constructor will be the arguments that were passed into the
ProductionWorker constructor.
You can find more about this, and examples, in the tutorials on this site:
http://www.cplusplus.com/doc/tutorial/inheritance/