Implicit type conversions are done by compiler where it is possible. This is also called as automatic type conversion or coercion.

C++ language core provides some rules known as standard conversions to specify how some fundamental data types (and other such as pointers, references etc.) are converted to another type.

There are 14 different standard conversions which are broadly divided into 5 groups.

  1. Numeric promotions: converting float to double, char to int, boolto int etc.
  2. Numeric conversions: converting float to int etc.
  3. Qualification conversions: <tobe added after understanding>
  4. Value conversions: <tobe added after understanding>
  5. Pointer conversions: Conversions from std::nullptr to other point types.

If compiler can’t do a conversion, it raises compilation error. For example, converting a string to int as shown below.

int value {"12"};

Brace initialization also raises error for narrow conversions, such as float to int as shown below.

int value {3.0};

References

  1. https://www.learncpp.com/cpp-tutorial/implicit-type-conversion/