H
Hattuari
On page 32 of TC++PL SE is an example of a complex class as follows:
class complex {
double re, im;
public:
complex(double r, double i){re=r; im=i;}
//...
};
On page 262 of TC++PL SE is an example of a complex class as follows:
class complex {
double re, im;
public:
complex(double r, double i):re(r), im(i){}
//...
};
I understand that in the latter the re(r) and im(i) are in the member
initialization list, whereas in the former the re=r; and im=i; are in the
function body of the constructor. What I'm not clear on is the implication
of doing things one way or the other. Also confusing is the difference in
syntax between re=r and re(r). Where is this latter form introduced in the
text? Where can it be used? How is it different from re=r? How should I
read in in English?
--STH
class complex {
double re, im;
public:
complex(double r, double i){re=r; im=i;}
//...
};
On page 262 of TC++PL SE is an example of a complex class as follows:
class complex {
double re, im;
public:
complex(double r, double i):re(r), im(i){}
//...
};
I understand that in the latter the re(r) and im(i) are in the member
initialization list, whereas in the former the re=r; and im=i; are in the
function body of the constructor. What I'm not clear on is the implication
of doing things one way or the other. Also confusing is the difference in
syntax between re=r and re(r). Where is this latter form introduced in the
text? Where can it be used? How is it different from re=r? How should I
read in in English?
--STH