LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-15-2004, 05:36 PM   #1
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Rep: Reputation: 47
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?

Last edited by exodist; 03-15-2004 at 05:42 PM.
 
Old 03-15-2004, 05:43 PM   #2
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
I feel stupid now, I know whats wrong :-[
 
Old 03-15-2004, 05:52 PM   #3
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Operator Overloading problem ashwinipahuja Programming 1 06-23-2004 05:59 AM
c++ [] operator overloading exodist Programming 12 04-17-2004 03:06 PM
Builtin operator overloading. exodist Programming 15 03-11-2004 10:41 PM
Operator Overloading - Java? Tesl Programming 4 02-13-2004 12:54 AM
C++ overloading extraction operator petercool Programming 5 09-06-2003 06:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration