ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  C++ General
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
What is conversion constructor?
 Question Submitted By :: Vasudevan
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is conversion constructor?
Answer
# 1
This is related to typecasting of user defined datatypes ie 
Convertion of one class object to other class object.
Ex 
I want to type cast REAL class object to COMPLEX Class object
Both REAL class and COMPLEX Class are user defined.

COMPLEX  objComplex(6,3); //6 is real and 3 is imagnary
REAL objReal(5);
objComplex=objReal; 
//end result of the above statement should be that
objComplex //should have 5 as real part and 0 as imaginary
//There are two solutions to it 
//a)write conversion constuctor 
//b)Overload assignment operator
// (a) for this add this in the COMPLEX Class
COMPLEX :: COMPLEX(REAL r)
{
real=r.value; // value is the only data member of REAL class
imag=0;
}   





 
Is This Answer Correct ?    0 Yes 0 No
Sachin Mahajan
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
Is there something that we can do in C and not in C++? Patni6
What happens if an exception is throws from an object's constructor and from object's destructor? TCS2
How to implement flags? Symphony1
wrong statement about c++ a)code removably b)encapsulation of data and code c)program easy maintenance d)program runs faster  8
What is the use of static functions? Symphony6
write program for palindrome  3
How the V-Table mechanism works? HP3
What is the difference between Class and Structure? HP2
How to avoid changing constant values? Symphony1
class HasStatic { static int I; }; Referring to the sample code above, what is the appropriate method of defining the member variable "I", and assigning it the value 10, outside of the class declaration? a) HasStatic I = 10; b) int static I = 10; c) static I(10); d) static I = 10; e) int HasStatic::I = 10; Quark1
difference between c and c++? Infosys8
why can't we declare data member of class auto register or extern  1
Write a program that read 2o numbers in and array and output the second largest number. Can anybody help??  2
What will happen if I allocate memory using "new" and free it using "free" or allocate sing "calloc" and free it using "delete"?  2
Which one of the following describes characteristics of "protected" inheritance? a) The base class has access only to the public or protected members of the derived class. b) The derived class has non-public, inheritable, access to all but the private members of the base class. c) The derived class has access to all members of the base class. d) The private members of the base class are visible within the derived class. e) Public members of the derived class are privately accessible from the base class. Quark3
is throwing exception from a constructor not a good practice ? Ericsson4
How do I open binary files?  1
Why preincrement operator is faster than postincrement?  3
What happens if an exception is throws from an, object's constructor and object's destructor? Wipro1
Can inline functions have a recursion? Give the reason?  1
 
For more C++ General Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com