I have an abstract class command-line, and many derivative classes are:
class CommandPath {Public: Virtual Commands Response Handmand (Standard :: String) = 0; Virtual CommandResponse executed () = 0; Virtual ~ commandpath () {}}; GetTimeCommandPath class: public command line {int stage; Public: GetTimeCommandPath (): Step (0) {} commanderspons handle comment (standard :: string); CommanderSports executed (); };
In all derived classes, the member variable is the 'step', I want to create a function in all those who use 'platform' in the same way, so to define it several times Instead I thought I would make it in the original class. I moved the 'step' from the private classes of all derived classes in the protected section of the commandpath and added the work as follows:
class commandpath {protected: int stage; Public: Virtual CommandResponse handleCommand (std :: string) = 0; Virtual CommandResponse executed () = 0; Std :: string confirmCommand (std :: string, int, int, std :: string, std :: string); Virtual ~ commandpath () {}}; Class GetTimeCommandPath: Public Commands Path {Public: GetTimeCommandPath (): Step (0) {} CommandResponse handleCommand (std :: string); CommanderSports executed (); };
Now my compiler asks me for the constructor line that none of the derived sections are 'platform'. I was under the impression that protected members are visible to the derived sections?
The constructor is the same in all classes, so I think I can move it to the original class, but I am more worried about why derived classes are not able to use the variable.
In addition, I have already used the original class for pure virtual tasks, I wanted to confirm that this is the way to go about it.
Try this:
class commandpace {protected: int stage; Public: Commandpath (int step_): step (step_) {}}; GetTimeCommandPath class: public command line {public: GetTimeCommandPath (int stage_): commandpath (step_) {}};
(additional code omitted for short)
You can not use the initial list on members of any original class, only if it is understandable Comes in
Comments
Post a Comment