MC++ FAQ
Thursday 06 | 27 | 2002
Using Overloaded Operators
Why can't I use the overloaded operators on type 'X'? If type 'X' is a reference object, you won't be able to consume any of the overloaded managed operators it might have defined. This is because there's a real impedance mismatch between operator overloading and the fact that in MC++ reference objects have to be accessed through pointers. Since standard C++, from which MC++ sort of came out, explicitly defines semantics for standard operators on pointers, such as the meaning of order relations (<, >, =, etc.), the use of actual operators would conflict with them.

Note that you should be able to use some overloaded operators on value types, though.

Posted by tomasr at June 27, 2002 01:07 AM
Comments

References are a good way around this and the proper way to deal with the situation, since the are also inter-operable with C#.
See pp93-94 "Programming With Managed Extensions for Microsoft Visual C++ .NET" by Richard Grimes (MS Press, ver 2003). It's also mentioned in "Essential Guide to Managed Extensions for C++" by Challa and Laksburg but I don't have that one on me right now...

Posted by: Adam on July 11, 2003 11:03 PM
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?

Copyright(C) 2002, Tomas Restrepo, All rights reserved. Powered by Movable Type 2.63