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
processing two jobs through 2 machine

Described the ISA and HASA class relationships. How would you apply each in a class design? A: A specialized class "is" specialization of another class and, thus, has the ISA re

THEORY OF A COMPUTER PROGRAMMING

C Program for EVEN & ODD NO IN ANY MATRICES #include stdio.h> #include conio.h> void main() {           int a[100][100];           int i=0,j=0,r,c,even=0,odd=0;

A: Depends. Might be "zero" Objects which are thrown must have a publicly accessible copy-constructor. The compiler is permitted to generate code which copies the thrown object

Charity Ball Organizer Many charities support good causes, but one of the difficulties each of them has is organizing their fundraising events. After nearly a semester of C progra

Structures A structure is a derived data type. It is a combination of logically related data items. Unlike arrays, which are a collection of such as data types, structures can

Define the System Oriented Data Files? System-oriented data files are further closely related to the computer's operating system than Stream- oriented data files and they are s

padovan string for a natural number is defined

array itself is a pinter.explain