+ 3

What is Implicit Conversion and Explicit Conversion?

What is Implicit Conversion and Explicit Conversion in C++? I did some web research, but there are various answers. Hopefully can get some help from here. Thanks :)

14th Jan 2018, 4:07 AM
James Hoe
James Hoe - avatar
7 Respostas
+ 27
generally , in implicit type conversion ... lower data types are directly converted to higher datatypes without any use of casting example ::: int to double type ☺ for explicit type conversion, u need to use type cast operator for converting higher datatype to lower one for example ::: int a=(int)3.5; //double to int type //am i correct @immortal //bcz its for java , might c++ also have some similarily
14th Jan 2018, 4:29 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 8
Implicit Conversion : double a= 123.33; int b=a; cout<<b; //prints 123 only Double -> int by the compiler itself Explicit Conversion : ■ int a= 65; char b= char(a); cout<<b; //prints 'A' we used the ASCII value here 65 -> 'A' // char b= a; also gives the same ■ double a= 65.6666666666; double b= float(a); cout<<b; //prints 65.6667
21st Jan 2018, 5:45 PM
I'm_Groot
I'm_Groot - avatar
+ 3
@Gaurav Agrawal Thank you so much! I understond it instantly HA-HA
14th Jan 2018, 4:31 AM
James Hoe
James Hoe - avatar
+ 3
both answers are awesome and really helpful! thank you guys so much!!! @Immortal @Gaurav Agrawal //the question is a part of my assignment in college
14th Jan 2018, 4:45 AM
James Hoe
James Hoe - avatar
+ 2
@Immortal thank you too! thumbs up!
14th Jan 2018, 4:35 AM
James Hoe
James Hoe - avatar