定义一个复数(z=x+iy)类Complex,包含: 两个属性:实部x和虚部y 默认构造函数 Complex(),设置x=0,y=0 构造函数:Complex(int i,int j) 显示复数...
时间: 2023-06-16 10:07:57 浏览: 93
好的,以下是符合要求的Complex类定义:
```cpp
class Complex {
private:
int x; // 实部
int y; // 虚部
public:
// 默认构造函数
Complex() {
x = 0;
y = 0;
}
// 构造函数,设置实部和虚部
Complex(int i, int j) {
x = i;
y = j;
}
// 显示复数
void display() {
cout << x << "+" << y << "i" << endl;
}
};
```
使用示例:
```cpp
// 创建实部为1,虚部为2的复数
Complex c1(1,2);
c1.display(); // 输出 1+2i
// 使用默认构造函数创建复数
Complex c2;
c2.display(); // 输出 0+0i
```
相关问题
为什么x为实数时,y变化,sin(x+iy)的点在双曲线上
当x为实数时,sin(xiy)可以写成sinh(x)y + i*cosh(x)y,其中sinh和cosh是双曲函数。因此,当x为实数时,sin(xiy)的实部为sinh(x)y,虚部为cosh(x)y,它们分别随着y的变化呈现出双曲线的形状。这是因为双曲函数在数学上与双曲线有密切的联系。因此,当x为实数时,sin(xiy)的点在双曲线上移动。
为什么x为实数时,x变化,sin(x+iy)的点在椭圆
上运动?
因为 sin(xiy) 可以表示为 sin(x) cosh(y) + i cos(x) sinh(y),其中 cosh 和 sinh 分别是双曲函数。当 x 变化时,sin(x) 和 cos(x) 会在单位圆上运动,而 cosh(y) 和 sinh(y) 则会在双曲线上运动。因此,整个函数的点会在一个椭圆上运动。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![text/x-c++](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)