Hi,
Excuse me for accidentally post the incomplete message previously.
In main(), line
Number::makeComplex (1, 2);
calls
Number Number::makeComplex (double rpart, double ipart)
Then, it calls constructor:
Number::Number () : rep (0), referenceCount (0)
Next, it calls
Complex::Complex (double d, double e) : Number (BaseConstructor()),
rpart (d), ipart (e)
{
cout << "Constructing a Complex\n";
}
Next, it calls Complex constructor:
Complex::Complex (double d, double e) : Number (BaseConstructor()),
rpart (d), ipart (e)
Next, it calls member function:
void Number::redefine (Number *n)
My question comes here. When it runs line
return n; // nCaller
It calls constructor:
Number::Number (const Number &n): rep (n.rep), referenceCount (0)
I don't understand why it calls the above constructor.
For your reference, here is the console window message:
rep(0), referenceCount(1)
00000000, 1
Constructing a Complex
Constructing a Number using Number::Number
I think that I have not enought understanding on class inheritance.
Hopefully, the answer for this question can teach me some.
Can you help me out?
Thanks,