The following code compiles and runs just fine in C (at least according to 'gcc -std=gnu99'), but it fails to compile under C++, giving "line 5: error: cannot convert 'double' to 'double complex' in initialization". Does anybody know why?
#include "/usr/include/complex.h"
#include <stdio.h>
int main(int argc, char * argv[]) {
double complex a = 3; // ERROR ON THIS LINE
printf("%lf\n", creal(a));
return 0;
}
I realize there is another way of doing complex numbers in C++, but I have to use C complex numbers in C++, because that is how the legacy code I was given does things. Thanks if you can help!