-
November 26th, 2013, 12:44 PM
#1
Why must be overloaded in pairs?
The comparison operators, if overloaded, must be overloaded in pairs; that is, if == is overloaded, != must also be overloaded. The reverse is also true, and similar for < and >, and for <= and >=.
Why??????????????
Or
// Overloading '+' operator:
public static ComplexNumber operator+(ComplexNumber a, ComplexNumber b)
{
return new ComplexNumber(a.real + b.real, a.imaginary + b.imaginary);
}
// Overloading '-' operator:
public static ComplexNumber operator-(ComplexNumber a, ComplexNumber b)
{
return new ComplexNumber(a.real - b.real, a.imaginary - b.imaginary);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|