BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Operator overloading problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language)
View previous topic :: View next topic  
Author Message
Matti
Guest





PostPosted: Sat Oct 11, 2003 6:47 pm    Post subject: Operator overloading problem Reply with quote



Hello,

I have a problem comparing 2 values of type AnsiString using the ==
operator (C++ Builder 5).

I use another class called TValue, which also defines the == operator.
Now when I
try to compare 2 AnsiString Values the == operator of class TValue is
invoked.

How can I avoid that and force my program to use the operator defined
for the
AnsiString class.

Here you can see a short example of what I mean.

TValue::TValue(AnsiString Val) {
}

bool TValue::operator==(const TValue &iVal2) const {
return true;
}

test () {
AnsiString Val1, Val2;
Val1 = "Test";
Val2 = "Test";

if (Val1 == Val2) {
}
}

Thank you for your help,

Matti
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.