#include <iostream>
#include <string>
using namespace std;
class Complex
{
private:
double real, imag;
public:
Complex(
double r);
Complex(
double r,
double i);
Complex(Complex c1, Complex c2);
};
Complex::Complex(
double r)
{
real = r; imag =
100;
cout <<
real <<
"--" << imag << endl;
}
Complex::Complex(
double r,
double i)
{
real = r; imag = i;
cout <<
real <<
"--" << imag << endl;
}
Complex::Complex(Complex c1, Complex c2)
{
real = c1.
real + c2.
real;
imag = c1.imag + c2.imag;
cout <<
real <<
"--" << imag << endl;
}
int main()
{
Complex c0;
Complex c1(
3);
Complex c2(
1,
2);
Complex c3(c1, c2);
Complex c4 =
5;
Complex c5 = {
10,
15 };
return 0;
}
转载请注明原文地址: https://ju.6miu.com/read-664630.html