RAD Studio |  |

E2354: Two operands must evaluate to the same type (C++)

The types of the expressions on both sides of the colon in the conditional expression operator (?:) must be the same, except for the usual conversions.

These are some examples of usual conversions

- char to int
- float to double
- void* to a particular pointer

In this expression, the two sides evaluate to different types that are not automatically converted.

This might be an error or you might merely need to cast one side to the type of the other.

When compiling C++ programs, this message is always preceded by another message that explains the exact reason for the type mismatch.

That other message is usually "Cannot convert 'type1' to 'type2'" but the mismatch might be due to many other reasons.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!