Home > Back-end >  Online to see, for example, there is a question that the custom class not overloaded operators, how
Online to see, for example, there is a question that the custom class not overloaded operators, how

Time:12-27


#include

using namespace std;



The class Complex

{

Public:

Complex (double r, double I) : real (r), imag (I) {}

Operator double ()

{

cout <"Type conversion function called" & lt;
Return real;

}

Private:

Double real;

Double imag;

};



Int main ()

{

Complex C (1, 2);

Double a=3.3;

cout
return 0;

}

CodePudding user response:

Because he can automatically converted to double
  • Related