conversion functionsconversion functions are


Conversion Functions

Conversion functions are member functions used for the following purposes:

1. Conversion of object to basic data type.

2. Conversion of basic data type to object.

3. Conversion of objects of dissimilar classes.

Conversions of one basic data type to another are automatically done by the compiler using its own built-in routines (implicit) and it can be forced using built-in conversion routines (explicit). Though, since the compiler does not know anything about user-defined types (classes), the program has to explain conversion functions.

e.g.

                int i = 2, j =19;

                float f = 3.5;

                i = f;  // i gets the value 3 , implicit conversion

                f = (float) j; // f gets 19.00, explicit conversion

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: conversion functionsconversion functions are
Reference No:- TGS0309401

Expected delivery within 24 Hours