I don't understand the customer accounts messages. I think it must be some configuration of your environment which is picking up references from a previous project.
However, I do see a problem here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
class Complex
{
public:
Complex();
private:
double *real_;
double *imaginary_;
};
Complex::Complex()
{
*real_ = 0.0;
*imaginary_ = 0.0;
}
|
Variables real_ and imaginary_ are uninitialised pointers to type double.
They will contain some random values which happened to be there already.
Then at lines 13 and 14, an attempt is made to write the value 0.0 to these random areas of memory.
If you are lucky, the program will crash with an exception. If you are unlucky, the program will continue to execute, having corrupted some area of memory which it has no right to access, with unpredictable effects at some later stage.
I don't see any reason why these values are pointers and not just variables of type double. But if you have a valid reason for using a pointer, memory must be allocated and the variable initialised to point to that memory.
Preferably just do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
class Complex
{
public:
Complex();
private:
double real_;
double imaginary_;
};
Complex::Complex()
{
real_ = 0.0;
imaginary_ = 0.0;
}
|
but if pointers are
really needed,
1 2 3 4 5 6 7 8 9 10 11 12 13
|
Complex::Complex()
{
real_ = new double;
imaginary_ = new double;
*real_ = 0.0;
*imaginary_ = 0.0;
}
Complex::~Complex()
{
delete real_;
delete imaginary_;
}
|