S
subramanian100in
I have tried the following in VC++ 2005 Express Edition and g++ in
Linux.
Consider the class
class my_complex
{
public:
my_complex(double r, double i = 10.0) : re(r), im(i) { }
my_complex(double r) : re(r), im(0) { }
private:
double re;
double im;
};
If I create an object like
my_complex c(100.0);
the compiler generates error as expected, due to ambiguity in the
ctors.
However if I do not create an object of my_complex, the compiler does
not
generate any warning or error. Why doesn't the compiler detect the
ambiguity
when an object of type my_complex is not created ? kindly explain.
Linux.
Consider the class
class my_complex
{
public:
my_complex(double r, double i = 10.0) : re(r), im(i) { }
my_complex(double r) : re(r), im(0) { }
private:
double re;
double im;
};
If I create an object like
my_complex c(100.0);
the compiler generates error as expected, due to ambiguity in the
ctors.
However if I do not create an object of my_complex, the compiler does
not
generate any warning or error. Why doesn't the compiler detect the
ambiguity
when an object of type my_complex is not created ? kindly explain.