#include
class Complex
{
public:
Complex(double r, double i)
: real(r)
, image(i)
{
}
Complex(const Complex& rhs)
{
this->real = rhs.real;
this->image = rhs.image;
}
void display()
{
std::cout << real << "+ i" << image << std::endl;
}
private:
double real;
double image;
};
int main(int argc, char** argv)
{
Complex c1(20, 40);
Complex c2(0, 0);
Complex c3(c1);
c1.display();
c2.display();
c3.display();
return 0;
}
没编译过,你自己验证一下,有问题跟帖。