Answer Posted / swarna sekhar dhar
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:
/ spec1_conversion_constructors.cpp
class Point
{
public:
Point();
Point( int );
//...
};
int main()
{
}
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.
Is This Answer Correct ? | 16 Yes | 1 No |
Post New Answer View All Answers
What is the use of 'using' declaration in c++?
Do you need a main function in c++?
How a pointer differs from a reference?
What is the difference between set and map in c++?
Explain what data encapsulation is in c++?
What is the benefit of encapsulation?
What is virtual table?
What is istream and ostream in c++?
What is a c++ map?
Which format specifier is used for printing a pointer value?
Is c++ the hardest programming language?
Explain shallow copy?
What is the use of :: operator in c++?
What jobs can you get with a c++ certification?
How the programmer of a class should decide whether to declare member function or a friend function?