想写个阻抗类如下,
class IMPEDANCE {
public:
IMPEDANCE(std::complex<float> z) : _z(z)
{
}
IMPEDANCE(void) : _z(0)
{
}
IMPEDANCE& operator=(const std::complex<float>& z)
{
this->_z = z;
return *this;
}
private:
std::complex<float> _z;
};
目前这几种初始化都正常
IMPEDANCE z1(18 - 45j);
IMPEDANCE z2(0);
IMPEDANCE z3;
z3 = 18 - 45j;
但是写 IMPEDANCE z4 = 18 + 45j; 就会报错,
app.cc:38:23: error: conversion from '__complex__ int' to non-scalar type 'IMPEDANCE' requested
我应该是还漏了什么...
--
FROM 222.129.0.*