Confused about class equality

Justin Spahr-Summers Justin.SpahrSummers at gmail.com
Sun Apr 4 13:57:29 PDT 2010


On Sun, 04 Apr 2010 13:14:29 -0400, strtr <strtr at spam.com> wrote:
> 
> Ali Çehreli Wrote:
> > 
> > The code works as expected with 2.042
> > 
> > I had to modify the toString() functions to return string, and say 
> > "override" in C's toString definition; and had to modify the writefln() 
> > calls:
> > 
> >    writefln("%s : %s %s", i2.toString(), i2.__vptr, i2.__monitor);
> > 
> > The output:
> > 
> > Same Value.
> > Same Object.
> > 3 : 806D3F4 0
> > 3 : 806D3F4 0
> > 5 : 806D3F4 0
> > 5 : 806D3F4 0
> > 
> > Ali
> 
> I probably wasn't clear about what exactly my problem is :
> Somehow in my (D1) program two object references have different vpointers/monitors and thus fail in "is" equality but I can change both objects with one call.

Again, without seeing the *actual* code that you are using, it's hard to 
say. The first thing that comes to mind is maybe a syntactical mistake, 
such as "i1.value = i2.value" when a comparison was intended, but there 
could be something else at play too, and without seeing the code (which 
is not the same as what you included in your first message) it's 
impossible to ascertain.


More information about the Digitalmars-d-learn mailing list