Problem
I am compiling my C++ application and getting the error:
"class.C", line 14: error: bad operand for ++: iterator
The failure seems to relate to the code:
class iterator { public: iterator(const collection &aCollection); void start(); const baseObject *operator++(int); };
Cause
This problem highlights a problem in the version of cfront 3.0.2 that is used for the C++ compiler in SCO OpenServer Development System Release 5.0.
The cfront 3.0.2 preprocessor will reject the overloading of the operator++ function as used in the example above.
NOTE: The overloading of C++ functions allows the same function name to
be used more than once for different implementations, each
implementation of the function being distinguished by either the
type or number of its parameters. Solution
By declaring the prefix operator++(), cfront 3.0.2 will correctly handle the postfix operator++(int). For example:
class iterator { public: iterator(const collection &aCollection); void start(); const baseObject *operator++(int); // postfix operator const baseObject *operator++(); //prefix operator };
This has been reported to SCO Engineering and is scheduled to be corrected in a future release of the C++ compiler.