Solved

What is a conversion constructor?

Posted on 2002-07-12
9
338 Views
Last Modified: 2012-05-04
What is a conversion constructor?
0
Comment
Question by:sambasivam
9 Comments
 

Author Comment

by:sambasivam
ID: 7149312
What is a conversion constructor?
0
 
LVL 86

Accepted Solution

by:
jkr earned 300 total points
ID: 7149339
A 'conversion ctor' will construct an object from a different data type, and that's why they are called that way. They take a single non-default argument which is not of the same type than the conversion target. Here's an example from the VC++ docs that illustrates it:

Conversion Constructors
A constructor that can be called with a single argument is used for conversions from the type of the argument to the class type. Such a constructor is called a conversion constructor. Consider the following example:

class Point
{
public:
   Point();
   Point( int );
   ...
};

Sometimes a conversion is required but no conversion constructor exists in the class. These conversions cannot be performed by constructors. The compiler does not look for intermediate types through which to perform the conversion. For example, suppose a conversion exists from type Point to type Rect and a conversion exists from type int to type Point. The compiler does not supply a conversion from type int to type Rect by constructing an intermediate object of type Point.
0
 
LVL 86

Expert Comment

by:jkr
ID: 7154264
As you just were around regarding http://www.experts-exchange.com/cplusprog/Q_20322631.html - do you have any more questions on this one?
0
 
LVL 86

Expert Comment

by:jkr
ID: 7163757
is there anything that you would like to ask as a followup?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 86

Expert Comment

by:jkr
ID: 7170823
Hmm, are you still with us?
0
 
LVL 86

Expert Comment

by:jkr
ID: 7178451
sambasivam? Do you need more explanation?
0
 
LVL 11

Expert Comment

by:griessh
ID: 7376035
Dear sambasivam

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "jkr"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 

Expert Comment

by:KalluMama
ID: 12765764
where can i find more information on conversion constructor
0
 
LVL 86

Expert Comment

by:jkr
ID: 12765915
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now