Here, TAdditionDispatcherImplementation derives from MAdditionProtocol:
class TAdditionDispatcherImplementation : public MAdditionProtocol { public: MCollectibleDeclarationsMacro(TAdditionDispatcherImplementation); public: TAdditionDispatcherImplementation(); TAdditionDispatcherImplementation( const TAdditionDispatcherImplementation& source); ~TAdditionDispatcherImplementation(); TAdditionDispatcherImplementation&operator=( const TAdditionDispatcherImplementation& source); virtual TStream& operator>>=(TStream& toStream) const; virtual TStream& operator<<=(TStream& fromStream); virtual long Add(long num1, long num2); virtual void AddOne(long& num); virtual void Shutdown(); protected: void TestForOverflowAndUnderflow(long num1, long num2); private: enum {kOriginalVersion}; };
long TAdditionDispatcherImplementation::Add(long num1, long num2) { TestForOverflowAndUnderflow(num1, num2); return num1 + num2; } void TAdditionDispatcherImplementation::AddOne(long& num) { if (num == LONG_MAX) { throw TMathException(TMathException::kOverflow); } ++num; }