What is the difference between type casting and type conversion in C++ or Java?

后端 未结 8 1476
Happy的楠姐
Happy的楠姐 2020-12-13 20:15

What is the difference between typecasting and typeconversion in C++ or Java ?

8条回答
  •  囚心锁ツ
    2020-12-13 21:04

    Type conversion:

    double value = 3; // implicit conversion to double value 3.0
    int nValue = 3.14156; // implicit conversion to integer value 3
    

    Casting is a request by the programmer to do an explicit type conversion.

    int nValue = 10;
    double dvalue = double(nValue); // explicit type casting
    

提交回复
热议问题