|
|
|
|||||
|
operator== of C++ classes
in the documentation's section C++ mapping for classes, it says
operator== operator!= operator< operator<= operator> operator>= The comparison operators permit you to use classes as elements of STL sorted containers. Note that sort order is based on the data members of the class, as for structures (see Section 6.12). But when I tried to use it and looked into the source code, it turns out the current implementation merely conpairs the two pointers. My question is, is it going to be implemented in the future or was it an old feature and won't be there any more? I just happen to need this now and it seems impossible to get around the problem except to write my own member-wise comparison code. |
|
||||||
|
You must be looking at an old version of the manual. (I think this was a bug in the manual, but it has been fixed for quite some time now.)
Have a look at http://www.zeroc.com/doc/Ice-3.2.0/manual/Cpp.7.14.html (last sub-chapter): Quote:
Last edited by marc : 06-21-2007 at 05:48 PM. |
|
||||||
|
Oops... I just noticed that we indeed still have this sentence in the manual:
Quote:
|
|
|||||
|
thanks! That clarifies a lot.
I guess you should remove the == operator that takes two references (if that's easy to do). The paragraph you referenced above only talks about class handle compison, and that's intuitive to understand given that it's name is smart POINTER. What i did is class A {...}; int main() { APtr a = new A; APtr b = new A(a); cout<< (*a==*b); <-- this still only compares address} |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Operator Error - NullHandleException | eric.hill | Help Center | 3 | 07-19-2006 07:10 PM |
| C# classes | semerich | Comments | 3 | 02-08-2006 09:23 AM |
| slice2cpp does not support copy construct and operator = | damingyipai | Comments | 3 | 06-17-2005 02:43 AM |
| Freeze Map iterator should add operator += n -=n | dragzhb | Comments | 4 | 10-18-2004 11:48 PM |
| About Classes transmit | level | Help Center | 4 | 09-22-2004 09:21 PM |