Mail Archives: djgpp/2004/03/31/06:45:07
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
From: | chris_tebbe AT yahoo DOT com (Chris)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Help with Operator Overloading
|
Date: | 31 Mar 2004 03:33:49 -0800
|
Organization: | http://groups.google.com
|
Lines: | 33
|
Message-ID: | <b687bbff.0403310333.7c0503b7@posting.google.com>
|
NNTP-Posting-Host: | 63.240.155.66
|
X-Trace: | posting.google.com 1080732829 24727 127.0.0.1 (31 Mar 2004 11:33:49 GMT)
|
X-Complaints-To: | groups-abuse AT google DOT com
|
NNTP-Posting-Date: | Wed, 31 Mar 2004 11:33:49 +0000 (UTC)
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
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
- Raw text -