Conversion operator, C/C++ Programming

What is conversion operator? Explain it with example.

Posted Date: 2/13/2013 1:08:25 AM | Location : United States





Try this, it will definitely help you

Class can have a public method for particular data type conversions.

class Boo

{

double value;

public:

Boo(int i )

operator double()

{

return value;

}

};

Boo BooObject;

double i = BooObject; // assigning object to variable i of type double. 

now conversion operator gets called to assign the value.

Posted by Jack | Posted Date: 2/13/2013 1:10:23 AM


Related Discussions:- Conversion operator, Assignment Help, Ask Question on Conversion operator, Get Answer, Expert's Help, Conversion operator Discussions

Write discussion on Conversion operator
Your posts are moderated
Related Questions
the issue of oil spills

Project Description: I posted listings on a site that is like eBay but for video games. I post the similar listing many times daily, but need something that will let me post


Write a function that has a single int parameter n and returns an int: 0 if n is negative, otherwise 1. You are not allowed to simply check the integer value, and should use the fu

a) Define an Asset base class that provides the following method: class Asset { public:      virtual double getValue()=0; };   This will be the base class for both stock an

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Damjibhai and Shamjibhai are two jeweler friends. They decide to play a simple game. The game comprises of removing the jewels for polishing, turn by turn. Once a jewel is removed

I need website Product section search box coding section fix Project Description: On our products section in the search box it only searches the name and title of our product

how to use and what is implicit and explicit constructor