0

Hi I am working with complex number and numeric computation a lot. I am new in C++. In Visual Studio 2015 the following code WORKS.

#include <complex>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    complex<double> a = 1.0 + 2i;
    cout << a << endl;
    system("pause");
}

However in Clion this gives me error like this

35: error: unable to find numeric literal operator 'operator""i' complex<double> a = 1.0 + 2i;

Please help me. Many Thanks!!!

niuniu
  • 9
  • 1
  • Different type, exact same issue. Read the [docs](http://en.cppreference.com/w/cpp/numeric/complex/operator%22%22i). – Baum mit Augen Apr 22 '16 at 01:02
  • I change the code to the following #include #include int main() { using namespace std::complex_literals; std::complex a = 1+1i; return 0; } It still didn't work. The error are: 26: error: expected namespace name using namespace std::complex_literals; – niuniu Apr 22 '16 at 02:43
  • Do you compile in C++14 mode? If not, please [edit] the question to include your updated [mcve] (good job on that btw) as well as your compiler, which compiler version you use and how you invoke it. – Baum mit Augen Apr 22 '16 at 09:40
  • Erm, I meant you should edit the question if compiling in C++14 mode does not help, not the other way around. Sorry. Btw, apart from the wrong type of the first summand in your comment, that code appears to be correct and works in a C++14 compiler. http://coliru.stacked-crooked.com/a/d2961d3545111d98 – Baum mit Augen Apr 22 '16 at 10:33

0 Answers0