Hello,
I come from the background of C # and do not have much experience in C ++. To create clean code, I try to separate implementation and interfaces and use inheritance whenever possible. And when I tried to apply typical C # concepts to C ++, I had a problem that I could not solve yet. I guess this is probably trivial for an experienced C ++ programmer, but he drove me crazy for quite some time.
First I declare a base class (it does not contain logic at the moment, but in the future)
class PropertyBase : public IProperty
{
};
Then I define the interface for the properties
class IProperty
{
public:
virtual ~IProperty() {};
virtual PropertyBase correct(const ICorrector &corrector) = 0;
virtual PropertyBase joinWith(const PropertyBase &partner, const IRecombinator &recombinator) = 0;
};
: , , , . , PropertyBase. , PropertyBase, .
, , IProperty , :
class IProperty
{
public:
virtual ~IProperty() {};
virtual PropertyBase* correct(const ICorrector &corrector) = 0;
virtual PropertyBase* joinWith(const PropertyBase &partner, const IRecombinator &recombinator) = 0;
};
, , . , - .