+ 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 :)
5 Respuestas
+ 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
+ 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
+ 3
@Gaurav Agrawal Thank you so much! I understond it instantly HA-HA
+ 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
+ 2
@Immortal thank you too! thumbs up!