Explicit type casting operator in C++

Explicit type casting operator
Type casting operators allow you to convert a datum of a given type to another. There are several ways to do this
in C++. The simplest one, which has been inherited from the C language, is to precede the expression to be
converted by the new type enclosed between parentheses (()):
int i;
float f = 3.14;
i = (int) f;
The previous code converts the float number 3.14 to an integer value (3), the remainder is lost. Here, the
typecasting operator was (int). Another way to do the same thing in C++ is using the functional notation:
preceding the expression to be converted by the type and enclosing the expression between parentheses:
i = int ( f );
Both ways of type casting are valid in C++.


Learn More :