[Uml-devel] CVS update & problem

Paul Hensgen phensgen at bigpond.net.au
Wed Jul 17 14:51:01 UTC 2002


Hi,

Its code entered by Luis, I just put it in CVS.  I am still thinking about 
what should be done here.  You are correct with your logic.  I don't think 
the method is ever called so is low priority.

I think QPtrList allows a simple == operator which do all the work so it just 
needs to be changed ot that. list1 != list2


Paul

>
> I just had a look and noticed that you were able to checkin some changes to
> sourceforge. I noticed, that Paul changed the list comparison in
>
>   bool UMLOperation::operator==( UMLOperation & rhs )
>
> to
>
>   if( &m_List != &(rhs.m_List) )
>
> In my opinion, this is not correct, as it compares the addresses of the
> list, not their contents. To proof this, I analyzed the QT source at that
> point and wrote the following little test program which I want to share
> with you:
>
>
> #include <qlist.h>
> #include <iostream>
>
> int main()
> {
>         QList<int> a;
>         QList<int> b;
>         bool res;
>
>         a = b;
>         res  = a == b;
>         cout << "1) a == b returns " << res << endl;
>
>         res = &a == &b;
>         cout << "2) &a == &b returns " << res << endl;
>
>         res = !(a == b);
>         cout << "3) !(a == b) returns " << res << endl;
>
>         res = &a != &b;
>         cout << "4) &a != &b returns " << res << endl;
>         return 0;
> }
>
>
> The results are:
>
> 1) a == b returns 1
> 2) &a == &b returns 0
> 3) !(a == b) returns 0
> 4) &a != &b returns 1
>
>
> As one can see, the same two lists might have the same contents but
> different addresses (as they are stored with different objects).
>
> I would assume, that 3) is the correct result not 4).
>
> Or am I missing something here? Please tell me if I am completely wrong,
> because then I have to consider to go back to the books on C++ again.
>
> - --
>
>
> Regards
>
> Thomas Baumgart
>
> home: thb at net-bembel.de              WWW: http://www.net-bembel.de/
> Check the KMyMoney2 open source project at http://kmymoney2.sf.net/






More information about the umbrello-devel mailing list