Unicorn with delicious cookie
Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter
to the top
>
>
>
Implicit type conversion

Implicit type conversion

30 Oct 2010

Implicit type conversion, also known as "coercion", is an automatic type conversion by the compiler. Implicit conversions do not require any operator. They are automatically performed when a value is copied to a compatible type. In a mixed type expression, a subtype s will be converted to a supertype t or some subtypes s1, s2, ... will be converted to a supertype t (maybe none of the s{i} is of type t) at runtime so that the program will run correctly. For example:

double d;
long l;
int i;
if (d > i)
  d = i;
if (i > l)
  l = i;
if (d == l)
  d *= 2;

Although d, l and i belong to different datatypes, they will be automatically converted to the same datatype each time a comparison or assignment is executed.

References

Popular related articles

S'abonner

Comments (0)

close comment form
close form

Remplissez le formulaire ci‑dessous en 2 étapes simples :

Vos coordonnées :

Étape 1
Félicitations ! Voici votre code promo !

Type de licence souhaité :

Étape 2
Team license
Enterprise licence
** En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité
close form
Demandez des tarifs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
USD
EUR
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
La licence PVS‑Studio gratuit pour les spécialistes Microsoft MVP
close form
Pour obtenir la licence de votre projet open source, s’il vous plait rempliez ce formulaire
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
I want to join the test
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
check circle
Votre message a été envoyé.

Nous vous répondrons à


Si l'e-mail n'apparaît pas dans votre boîte de réception, recherchez-le dans l'un des dossiers suivants:

  • Promotion
  • Notifications
  • Spam