I basically have two classes: Signal
and Parser
they both have differences, however, they each share the data that Signal
has.
I want to incorperate Method Chaining into the class, so my classes (at the moment look like the following):
class Signal {
Signal() {
}
Signal& Parse()
{
return *(this);
}
};
And my other class looks like the following:
class Parse : public Signal {
Parse() {
}
};
This will therefore allow me to do the following in main: Signal s = Signal().Parse();
But what I need to do is in the class Signal
when Parse
is called, initialise a new object of the class Parse
so it can do it's "business". The class constructor in Parse
will use the data in Signal
.
I know this is possible using CRTP, however, using CRTP would require me to have a template method for Signal, and, I cannot have this due to other classes inheirting from Signal.
Anyone know of an alternative to solving such problem?
Thanks