Regarding the class definition for a complex number, I saw two types of definitions:
Definition 1
class Complex
{
private:
double re;
double im;
public:
Complex(float r,float i) {re = r; im = i;}
~Complex() {};
};
Definition 2
class Complex
{
private:
double re;
double im;
public:
Complex(double r,double i): re(r), im(i) {}
~Complex() {};
};
The first definition looks good to me, but I don’t quite understand the second definition, how
Complex(double r,double i): re(r), im(i) {}
work? What does re () mean?
source
share