I'm trying to create a counter interface that forces all derived classes to implement this interface:
class CounterInterface
{
public:
virtual CounterInterface& operator ++ () = 0;
virtual CounterInterface operator ++ (int) = 0;
virtual CounterInterface& operator -- () = 0;
virtual CounterInterface operator -- (int) = 0;
virtual bool operator == ( const CounterInterface o ) const = 0;
virtual operator uint32_t () const = 0;
virtual void reset() = 0;
};
However, just including this class definition results in the error below.
Unfortunately post inc can't be defined as reference.
Any ideas how to resolve this chicken/egg problem?
CounterInterface.h:25:29: error: invalid abstract return type for member function ‘virtual libceis::CounterInterface libceis::CounterInterface::operator++()’
CounterInterface.h:22:8: note: because the following virtual functions are pure within ‘libceis::CounterInterface’:
CounterInterface.h:25:29: note: virtual libceis::CounterInterface libceis::CounterInterface::operator++()
CounterInterface.h:26:29: note: virtual libceis::CounterInterface libceis::CounterInterface::operator++(int)
CounterInterface.h:27:29: note: virtual libceis::CounterInterface libceis::CounterInterface::operator--()
CounterInterface.h:28:29: note: virtual libceis::CounterInterface libceis::CounterInterface::operator--(int)
CounterInterface.h:29:17: note: virtual bool libceis::CounterInterface::operator==(libceis::CounterInterface) const
CounterInterface.h:30:12: note: virtual libceis::CounterInterface::operator uint32_t() const
CounterInterface.h:31:17: note: virtual void libceis::CounterInterface::reset()
CounterInterface.h:26:29: error: invalid abstract return type for member function ‘virtual libceis::CounterInterface libceis::CounterInterface::operator++(int)’