delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/04/01/20:00:55

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-ID: <406C90BD.1A8D7D9E@alltel.net>
From: Curtis Mackie <curtmack AT alltel DOT net>
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: <b687bbff DOT 0403310333 DOT 7c0503b7 AT posting DOT google DOT com>
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

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
This might not work, but... Try changing Matrix&amp; operator* (double,
Matrix&amp;) into Matrix&amp; Matrix::operator* (double). You'll have to
reverse the arguments, ie:
<p><tt>&nbsp;&nbsp;&nbsp; weight=weight+(Matrix&amp;)(Deltaweight*rate)</tt>
<p>Chris wrote:
<blockquote TYPE=CITE>As a result of my last posting, I apparently have
a little catching up
<br>to do on the "new" C++ relative to updating my old programs.&nbsp;
So,
<br>here's another one for the DJGPP warriors:
<p>In my header file, I have overloaded "*" as follows:
<p>&nbsp;&nbsp;&nbsp; friend Matrix &amp; operator*(FLOAT_TYPE, Matrix
&amp;); // multiply
<br>scalar &amp; matrix
<p>Of course, this compiles nicely.&nbsp; In implementation as follows:
<p>&nbsp;&nbsp;&nbsp; double rate;
<br>&nbsp;&nbsp;&nbsp; Matrix DeltaWeight(4,4);
<br>&nbsp;&nbsp;&nbsp; Matrix weight(4,4);
<br>...
<br>&nbsp;&nbsp;&nbsp; weight=weight+(Matrix&amp;)(rate*(Matrix&amp;)DeltaWeight);
<br>...
<p>and I get the following error:
<p>connect.cc:88: error: ISO C++ says that `Matrix&amp; operator*(double,
<br>Matrix&amp;)' and `operator*' are ambiguous even though the worst
<br>conversion for the former is better than the worst conversion for the
<br>latter
<p>In my header file, I have also overloaded the double() function to
<br>allow the casting of a 1x1 matrix into a double, but here I have
<br>explicitly cast DeltaWeight as a Matrix as well as the result of the
<br>multiplication.
<p>As always, any help is appreciated.
<p>--Chris</blockquote>
</html>

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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019