Explain conversion functions, C/C++ Programming

Assignment Help:

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

 


Related Discussions:- Explain conversion functions

String, what is a string?

what is a string?

C code, get coding for padovan string

get coding for padovan string

Error handling and constructor, Provide me the answer, Can a constructor th...

Provide me the answer, Can a constructor throws an exception? How to handle the error when the constructor fails?

Is there any difficulty with the following : char*a=null; , Is there any di...

Is there any difficulty with the following : char*a=NULL; char& p = *a;? A: The result is indeterminate. You must never do this. A reference has to always refer to some object.

Compiler Design - Limit In The Method Instructions, Raj is a newbie to the ...

Raj is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with ''}''

Is there present a way to force new to allocate memory, Yes. "Memory pools"...

Yes. "Memory pools" are useful in many situations. The bad news is that I'll need to drag you through the mire of how it acts before we talk about all the uses. Firstly, recall

STRING, getting a palindrome using minimum replacement

getting a palindrome using minimum replacement

Vectors, A body which has three forces acting on it is in equilibrium. One ...

A body which has three forces acting on it is in equilibrium. One force is 3N to the North and the other is 4N to the west. What us the magnitude and direction of the third force?

Arrays, #questi An array of n numbers is given, where n is an even number. ...

#questi An array of n numbers is given, where n is an even number. The maximum as well as minimum of these given numbers need to be determined. Which of the following is true about

How does a union differ from a structure, Problem: (a) (i) What is a...

Problem: (a) (i) What is a structure? (ii) How does a structure differ from an array? (b) Declare a structure, called account, that will contain the following data me

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd