Board index » cppbuilder » Operator overloading problem
|
xmrf
CBuilder Developer |
Operator overloading problem2003-10-12 02:47:59 AM cppbuilder42 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 |
