I have this, but it's not working.
typedef struct complex {
double Re;
double Im;
complex operator=(double val){
complex retval;
retval.Re = val;
retval.Im = 0;
return retval;
}
} complex;
It's an overload of the assignment operator "=" and is supposed to make it easy to convert a real value into a complex value. The end result of the operation is intended that the complex value's real part will hold the desired number, and its imaginary part will be 0 (zero). However, I find that its real part remains 0. The assignment never gets performed. Please tell me what I'm doing wrong.