X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <406C90BD.1A8D7D9E@alltel.net> From: Curtis Mackie X-Mailer: Mozilla 4.5 [en]C-Alltel IS (Win98; I) X-Accept-Language: en-US, en-GB, en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Help with Operator Overloading References: Content-Type: multipart/alternative; boundary="------------CDD48D4729D3EB737F969B2F" Lines: 89 X-Complaints-To: abuse AT usenetserver DOT com X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly. NNTP-Posting-Date: Thu, 01 Apr 2004 19:57:47 EST Date: Thu, 01 Apr 2004 15:59:25 -0600 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com --------------CDD48D4729D3EB737F969B2F Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This might not work, but... Try changing Matrix& operator* (double, Matrix&) into Matrix& Matrix::operator* (double). You'll have to reverse the arguments, ie: weight=weight+(Matrix&)(Deltaweight*rate) Chris wrote: > As a result of my last posting, I apparently have a little catching up > to do on the "new" C++ relative to updating my old programs. So, > here's another one for the DJGPP warriors: > > In my header file, I have overloaded "*" as follows: > > friend Matrix & operator*(FLOAT_TYPE, Matrix &); // multiply > scalar & matrix > > Of course, this compiles nicely. In implementation as follows: > > double rate; > Matrix DeltaWeight(4,4); > Matrix weight(4,4); > ... > weight=weight+(Matrix&)(rate*(Matrix&)DeltaWeight); > ... > > and I get the following error: > > connect.cc:88: error: ISO C++ says that `Matrix& operator*(double, > Matrix&)' and `operator*' are ambiguous even though the worst > conversion for the former is better than the worst conversion for the > latter > > In my header file, I have also overloaded the double() function to > allow the casting of a 1x1 matrix into a double, but here I have > explicitly cast DeltaWeight as a Matrix as well as the result of the > multiplication. > > As always, any help is appreciated. > > --Chris --------------CDD48D4729D3EB737F969B2F Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit This might not work, but... Try changing Matrix& operator* (double, Matrix&) into Matrix& Matrix::operator* (double). You'll have to reverse the arguments, ie:

    weight=weight+(Matrix&)(Deltaweight*rate)

Chris wrote:

As a result of my last posting, I apparently have a little catching up
to do on the "new" C++ relative to updating my old programs.  So,
here's another one for the DJGPP warriors:

In my header file, I have overloaded "*" as follows:

    friend Matrix & operator*(FLOAT_TYPE, Matrix &); // multiply
scalar & matrix

Of course, this compiles nicely.  In implementation as follows:

    double rate;
    Matrix DeltaWeight(4,4);
    Matrix weight(4,4);
...
    weight=weight+(Matrix&)(rate*(Matrix&)DeltaWeight);
...

and I get the following error:

connect.cc:88: error: ISO C++ says that `Matrix& operator*(double,
Matrix&)' and `operator*' are ambiguous even though the worst
conversion for the former is better than the worst conversion for the
latter

In my header file, I have also overloaded the double() function to
allow the casting of a 1x1 matrix into a double, but here I have
explicitly cast DeltaWeight as a Matrix as well as the result of the
multiplication.

As always, any help is appreciated.

--Chris

--------------CDD48D4729D3EB737F969B2F--