Implicit Conversions in C++

Enter a reason for deleting this comment

Implicit Conversions in C++

Wecan mix data types in expressions. For example,

M = 5+2.75;
is a valid statement. Wherever data types are mixed in an expression, C++ performs
the conversions automatically. This process is known as implicit or automatic conversion.

Whenthe compiler encounters an expression, it divides the expressions into sub-expressions consisting of one operator and one or two operands. For a binary operator, if the operands type differ, the compiler converts one of them to match with the other, using the rule that the “smaller” type is converted to the “wider” type. For example, if one of the operand is an int and the other is a float,the int is converted into a float because a float is wider than an int.


Please login or sign up to leave a comment