Friday, 31 January 2020

Type Conversion


Type Conversion

? A type conversion may either be explicit or implicit, depending on whether it is ordered
by the programmer or by the compiler. Explicit type conversions (casts) are used when a
programmer want to get around the compiler’s typing system; for success in this endeavour,
the programmer must use them correctly.
? Used another constructor to build a string type object from a char* type variable.
? The general form of an overloaded casting operator function, also referred to as a conversion
function, is:
operator typename()
//Program statement
? Which form to use, depends upon where we want the type-conversion function to be
located, whether in the source class or in the destination class.

Implicit Conversion: An implicit conversion sequence is the sequence of conversions required
to convert an argument in a function call to the type of the corresponding parameter in a
function declaration.
Operator Type name(): Converts the class object of which it is a member to type name.

No comments:

Post a comment