Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!cit-vax!tybalt.caltech.edu!christ
From: christ@tybalt.caltech.edu (Christian L. Keppenne)
Newsgroups: comp.lang.c++
Subject: trivial question from a novice
Message-ID: <11578@cit-vax.Caltech.Edu>
Date: 13 Aug 89 23:35:08 GMT
Sender: news@cit-vax.Caltech.Edu
Reply-To: christ@tybalt.caltech.edu.UUCP (Christian L. Keppenne)
Organization: California Institute of Technology
Lines: 38

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 
#include 

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