C Complex Numbers in C++?

前端 未结 3 1527
长情又很酷
长情又很酷 2020-11-29 11:13

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 \'d

3条回答
  •  孤城傲影
    2020-11-29 12:10

    Compatibility of C and C++

    Several additions of C99 are not supported in C++ or conflict with C++ features, such as variadic macros, compound literals, designated initializers, variable-length arrays, and native complex-number types. The long long int datatype and restrict qualifier defined in C99 are not included in the current C++ standard, but some compilers such as the GNU Compiler Collection[4] provide them as an extension. The long long datatype along with variadic templates, with which some functionality of variadic macros can be achieved, are present in the new C++ standard, C++11. On the other hand, C99 has reduced some other incompatibilities by incorporating C++ features such as // comments and mixed declarations and code.

提交回复
热议问题