H
Heloise
Hi all,
I'm trying to write an overloaded operator for unary negation e.g.,
MyClass a(5);
MyClass b(0);
b = -a;
Here is my class implementation:
public ref class Angle
{
double radianValue; // value of the angle in radians
Angle():radianValue(0.0){};
Angle(double radians):radianValue(radians){};
Angle^ operator-()
{
return gcnew Angle(-radianValue);
}
}
My C# unit test code:
Angle angle1(10.0);
Angle angle2;
angle 2 = -angle1;
gives this error:
error CS0023: Operator '-' cannot be applied to operand of type 'Angle'
My other operators work fine.
Any ideas? Thanks in advance.
I'm trying to write an overloaded operator for unary negation e.g.,
MyClass a(5);
MyClass b(0);
b = -a;
Here is my class implementation:
public ref class Angle
{
double radianValue; // value of the angle in radians
Angle():radianValue(0.0){};
Angle(double radians):radianValue(radians){};
Angle^ operator-()
{
return gcnew Angle(-radianValue);
}
}
My C# unit test code:
Angle angle1(10.0);
Angle angle2;
angle 2 = -angle1;
gives this error:
error CS0023: Operator '-' cannot be applied to operand of type 'Angle'
My other operators work fine.
Any ideas? Thanks in advance.