PBanta
January 16th, 2007, 10:55 AM
Is it possible to overload the "+=", "-=", "*=", and "/=" operators in a managed class? If so, how (what is the CLS function name)?
|
Click to See Complete Forum and Search --> : += Operator Overloading PBanta January 16th, 2007, 10:55 AM Is it possible to overload the "+=", "-=", "*=", and "/=" operators in a managed class? If so, how (what is the CLS function name)? Zaccheus January 16th, 2007, 03:06 PM I don't think it is, because operators are declared as static methods in .net assemblies. Having said that, the following compiles just fine using /clr:safe ref class X { public: X^ operator*=(X^ a) {return this;} }; Table 19-5: C++-Dependent Binary Operators Metadata Function Name ... C++ Operator Function Name op_Addition ... operator+ op_AdditionAssignment ... operator+= op_Assign ... operator= op_BitwiseAnd ... operator& op_BitwiseAndAssignment ... operator&= op_BitwiseOr ... operator| op_BitwiseOrAssignment ... operator|= codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved. |