- 1
What is the difference between implicit and explicit typecasting in C++ ? Give with example.
2 odpowiedzi
+ 6
Implicit is where it automatically converts it. For example, lets say that I declared my variable as a double, but I use a normal integer as its value, it'll automatically convert it.
Explicit is where you actually use the casting to specify what type it'll convert to or should be.
EXAMPLE:
double d = 2; (it'll implicitly convert it to 2.0)
int d1 = 1;
int d2 = 2;
float d = (float)d1 + d2; (this will explicitly convert d1 to float, and the operation itself will automatically convert d2 also)
0
Thanks Netkos