Class CS and class Key are both children of class Action.
Class Key constructor takes an Action* parameter.
Key instantiation on line 34 compiles.
Key instantiation on line 37 does not compile; why is that?
C:\demo_MinGW>g++ aggregation.cpp
aggregation.cpp:37:21: error: no matching function for call to 'Key::Key(Shift (
*)())'
Key key_shift(&shift);
^
aggregation.cpp:37:21: note: candidates are:
aggregation.cpp:29:3: note: Key::Key(Action*)
Key(Action* const a): ptrAction(a) { }
^
aggregation.cpp:29:3: note: no known conversion for argument 1 from 'Shift (*)
()' to 'Action*'
aggregation.cpp:24:7: note: Key::Key(const Key&)
class Key
^
aggregation.cpp:24:7: note: no known conversion for argument 1 from 'Shift (*)
()' to 'const Key&'
In this context, shift is a function that takes no parameters and returns a Shift object.
Remove the parenthesis after it (from Shift shift(); to Shift shift;).