I wish to make each derived class of a base class to implement a function (in this case the postfix operator) which has the derived class' type as return type, as this:
class A {
virtual A operator++(int) =0;
}
class B : public A {
B operator++(int);
}
This generates errors of the kind return type 'A' is an abstract class
. What to do? As far as I understand the postfix must return the actual type and not a reference/pointer to the type.
What about using the CRTP pattern:
PS: just saw that @Marco A. posted a link with a similar approach. I will keep my answer for completeness, don't feel any pressure to vote it.