Udostępnij za pośrednictwem


Return and parameter types of '<operator>' must be '<typename>' to be used in a 'For' statement

A For loop specifies a counter variable of a type that does not define the + or - operator with parameters and return value of its own type.

The counter variable must be of a type that supports addition () and subtraction (-) operators that operate completely on their containing type. This means both of the operands and the return value must be of the type of the counter variable.

If you use a numeric data type for the counter variable, the + and - operators are supported on the containing type. If you use a user-defined class or structure, you must define both operators with operands and return value of the type of your class or structure.

Error ID: BC33039

To correct this error

  1. Make sure the spelling of the counter-variable data type is correct.

  2. If you are using a user-defined class or structure for the counter variable, define + and - operators that operate completely on that class or structure.

See Also

Tasks

How to: Define an Operator

How to: Define a Conversion Operator

Concepts

Operator Procedures

Reference

For...Next Statement (Visual Basic)

Operator Statement