title: C Complex Numbers in C++?
body: <p>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 <strong>complex</strong>' in initialization".  Does anybody know why?</p>
  
  <pre><code>#include "/usr/include/complex.h"
  #include &lt;stdio.h&gt;
  
  int main(int argc, char * argv[]) {
    double complex a = 3;  // ERROR ON THIS LINE
    printf("%lf\n", creal(a));
    return 0;
  }
  </code></pre>
  
  <p>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!</p>