+ 1

What is the difference between this:

#include <iostream> int main() { int b = 2; double a = b; std::cout << a; return 0; } and this: #include <iostream> int main() { int b = 2; double a = (double)b; std::cout << a; return 0; }

2nd Sep 2018, 5:11 PM
Oleg Storm
Oleg Storm - avatar
2 Respostas
2nd Sep 2018, 5:44 PM
Shadow
Shadow - avatar
+ 2
there isn't difference in the result, the explicit (double) conversion is not necessary. This is known as a standard conversion. Standard conversions affect fundamental data types, and allow the conversions between numerical types (short to int, int to float, double to int...),
2nd Sep 2018, 5:54 PM
Miguel Angel Acosta
Miguel Angel Acosta - avatar