On Mon, Jul 08, 2013 at 05:09:14PM -0700, Jonathan M Davis wrote:
> On Monday, July 08, 2013 16:58:03 H. S. Teoh wrote:
> > On Mon, Jul 08, 2013 at 04:48:05PM -0700, Jonathan M Davis wrote:
> > > On Monday, July 08, 2013 16:38:16 H. S. Teoh wrote:
> > [...]
> >
> > > > Basically, when you write x=
On Monday, July 08, 2013 16:58:03 H. S. Teoh wrote:
> On Mon, Jul 08, 2013 at 04:48:05PM -0700, Jonathan M Davis wrote:
> > On Monday, July 08, 2013 16:38:16 H. S. Teoh wrote:
> [...]
>
> > > Basically, when you write x==y, the compiler looks for opEquals and
> > > opCmp. If opEquals is found, the
On Mon, Jul 08, 2013 at 04:48:05PM -0700, Jonathan M Davis wrote:
> On Monday, July 08, 2013 16:38:16 H. S. Teoh wrote:
[...]
> > Basically, when you write x==y, the compiler looks for opEquals and
> > opCmp. If opEquals is found, then it's rewritten as x.opEquals(y);
> > otherwise, if opCmp is fou
On Monday, July 08, 2013 16:48:05 Jonathan M Davis wrote:
> On Monday, July 08, 2013 16:38:16 H. S. Teoh wrote:
> > On Tue, Jul 09, 2013 at 12:35:32AM +0200, Ugbar Ikenaki wrote:
> > > Here's one more question:
> > >
> > > Before I knew that opEquals existed, I tried overloading the
> > > equality
On Monday, July 08, 2013 16:38:16 H. S. Teoh wrote:
> On Tue, Jul 09, 2013 at 12:35:32AM +0200, Ugbar Ikenaki wrote:
> > Here's one more question:
> >
> > Before I knew that opEquals existed, I tried overloading the
> > equality expressions (== and !=) in opBinary using the code below.
> > It work
On Tue, Jul 09, 2013 at 12:35:32AM +0200, Ugbar Ikenaki wrote:
> Here's one more question:
>
> Before I knew that opEquals existed, I tried overloading the
> equality expressions (== and !=) in opBinary using the code below.
> It worked. Why would the overloaded opBinary version get called if
> th
On Tuesday, July 09, 2013 00:35:32 Ugbar Ikenaki wrote:
> Here's one more question:
>
> Before I knew that opEquals existed, I tried overloading the
> equality expressions (== and !=) in opBinary using the code
> below. It worked. Why would the overloaded opBinary version get
> called if the equal
Here's one more question:
Before I knew that opEquals existed, I tried overloading the
equality expressions (== and !=) in opBinary using the code
below. It worked. Why would the overloaded opBinary version get
called if the equality expressions are held in opEquals? I'm just
interested in kn
And thanks for that pointer, too, H.S.
Wow! You guys are fast and helpful! Thank you Jonathan and Ali! I
already got it to work, and Ali, your book is great! I've read
about the first 150 pages. I'll check out those operator
overloading chapters for sure.
-U
On Mon, Jul 08, 2013 at 02:42:30PM -0700, Jonathan M Davis wrote:
> On Monday, July 08, 2013 23:31:14 Ugbar Ikenaki wrote:
> > Also…Rat is a struct, not a class. Herein might lie the problem.
>
> So, this is Rat's opCmp, correct? If it's a struct, it makes no sense
> for it to take an Object. Obje
On 07/08/2013 02:21 PM, Ugbar Ikenaki wrote:
I'm trying to implement rational numbers with fully functioning
comparison operators, but I can't seem to figure out why I'm getting
this error and any help would be appreciated:
Error: cannot cast from object.Object to Rat
The code I have is as foll
On Monday, July 08, 2013 23:31:14 Ugbar Ikenaki wrote:
> Also…Rat is a struct, not a class. Herein might lie the problem.
So, this is Rat's opCmp, correct? If it's a struct, it makes no sense for it
to take an Object. Object is the base class for all classes and has nothing to
do with structs. o
Thanks for the quick response!
Here is the initialization code for my Rat struct. I created a
GCD function that I've tested to work fine:
import std.stdio, std.exception;
struct Rat {
private long n; //Numerator
private long d; //Denominator
Also…Rat is a struct, not a class. Herein might lie the problem.
On Monday, July 08, 2013 23:21:59 Ugbar Ikenaki wrote:
> I'm trying to implement rational numbers with fully functioning
> comparison operators, but I can't seem to figure out why I'm
> getting this error and any help would be appreciated:
>
> Error: cannot cast from object.Object to Rat
>
> The
I'm trying to implement rational numbers with fully functioning
comparison operators, but I can't seem to figure out why I'm
getting this error and any help would be appreciated:
Error: cannot cast from object.Object to Rat
The code I have is as follows:
int opCmp( Object o ) {
Rat ot
17 matches
Mail list logo