LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C# with dotGNU, operator overloading (https://www.linuxquestions.org/questions/programming-9/c-with-dotgnu-operator-overloading-158133/)

exodist 03-15-2004 05:36 PM

C# with dotGNU, operator overloading
 
I am lost, here is the code snippet:
---line 1006------
public static bool operator==(exdec lhs, exdec rhs)
{
return (lhs.Values == rhs.Values);
}
public static bool operator!=(exdec lhs, exdec rhs)
{
return (lhs.Values != rhs.Values);
}
public static bool operator<=(exdec lhs, exdec rhs)
{
return (lhs.Values <= rhs.Values);
}
public static bool operator>=(exdec lhs, exdec rhs)
{
return (lhs.Values >= rhs.Values);
}
public static bool operator>(exdec lhs, exdec rhs)
{
return (lhs.Values > rhs.Values);
}
public static bool operator<(exdec lhs, exdec rhs)
{
return (lhs.Values < rhs.Values);
}
---line 1031------

here is my error:

./exodist.cs:1017: invalid operands to binary `<='
./exodist.cs:1017: incompatible types in return: no conversion from `int' to `bool'
./exodist.cs:1021: invalid operands to binary `>='
./exodist.cs:1021: incompatible types in return: no conversion from `int' to `bool'
./exodist.cs:1025: invalid operands to binary `>'
./exodist.cs:1025: incompatible types in return: no conversion from `int' to `bool'
./exodist.cs:1029: invalid operands to binary `<'
./exodist.cs:1029: incompatible types in return: no conversion from `int' to `bool'

notes:
line 1216 has a } closing the namespace usage declairation on line #1
Values is an integer array (int[]) inside the exdec class.

why would == and != work then <= etc all fail w/ same syntax?

exodist 03-15-2004 05:43 PM

I feel stupid now, I know whats wrong :-[

exodist 03-15-2004 05:52 PM

obviously I cannot simply see if an array has a greater or smaller total added value like this :-P


All times are GMT -5. The time now is 02:18 PM.