[comp.lang.c++] trivial question from a novice

christ@tybalt.caltech.edu (Christian L. Keppenne) (08/14/89)

I am a newcomer to c++ who is encountering the following problem.
I need to be able to do operations on complex numbers in a setting
where a constructor with no argument has been defined. My sources
handles matrices of complex numbers and it will not compile if I use 
the complex type defined in the complex.h file found on our system 
because the constructor handles the case with no argument as
complex(double=0.0,double=0.0) { etc..... }

I only found two ways to handle this and both are not very elegant:
1) use my own customized version of the complex,h file
2) define a derived class to redefine the constructor as in the
following example:
 
#include <complex.h>
#include <stream.h>

class cplx: public complex 
{	public:
	cplx( ) : (0.0,0.0) { }
	cplx(double r) : (r,0.0) { }
	cplx(double r, double i) : (r,i) { }
} a,b;

main( )
{	
/* what I don't like is that "cout << a+b;" does not work so that I have 
to write: */
	cout <<  *((complex *) &a)+ *((complex *) &b);
}


I am sure there are more elegant ways to do this. Will someone help me?
As this is certainly a trivial question, it is probably be a good idea to 
reply by e. mail 

		thank you.

Christian Keppenne 	christ@tybalt.caltech.edu