小编gnh*_*nkz的帖子

在 C++11 中使用 cin 作为输入复数

#include <iostream>
#include <complex>
using namespace std;

int main(){
    complex<double> p;
    cin >> p.real() >> p.imag();
}
Run Code Online (Sandbox Code Playgroud)

在 g++4.7.2 中它成功运行,但在 C++11 中编译失败。为什么?

它给了我以下错误消息:

prog.cpp: In function ‘int main()’:
prog.cpp:7:19: error: no match for ‘operator>>’ in ‘std::cin >> p.std::complex<double>::real()’
Run Code Online (Sandbox Code Playgroud)

完整版:http : //ideone.com/M3BhVR

complex-numbers c++11

-2
推荐指数
1
解决办法
3218
查看次数

标签 统计

c++11 ×1

complex-numbers ×1