a function returning reference to real or imag values of a complex number in C++11
问题 I'm looking for a function that returns a reference to real or imag values of a complex number in C++11. In C++03 I could say: complex<double> C; cin >> C.real(); But in C++11 that gives me a compile error since the C.real() returns a value not a reference. I found out that I can write this: double t; cin >> t; C.real(t); but it isn't straightforward and for example if I want to multiply the real part of c by 2 and ad it by 1 I should say: C.real(2*C.real() + 1); That is not clean. Is there