Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Java operator overloading
Name: movitto Date: April 14, 2004 at 13:02:28 Pacific OS: Red Hat 8.0 CPU/Ram: P2
Comment:
Hi;
I have alot experience in C++ and now learning Java. When I try to compile a class file I get the following error for every operator I try to overload:
';' expected
number operator +(number temp){
(there is a carrot ^ symbol pointing to +) Where number is my class I am working with.
Is this because Java does not support operator overloading? If it doesnt is there a way to write the same syntax as above without defining an 'add' function such as
"Various operators in Groovy are mapped onto regular Java method calls on objects. This allows you the developer to provide your own Java or Groovy objects which can take advantage of operator overloading. The following table describes the operators supported in Groovy and the methods they map to."
http://groovy.codehaus.org/operators.html
I've never used Groovy. So I cannot help you with syntax, etc.
Summary: Hi all, I have got a basic doubt in Operator overloading. Suppose i want to overload an assignment operator,then the Source and target variables needs to be of the same calss type?Can a base class and...
Summary: hi.. i have some doubts in operator overloading... plz help me out. I'm having a BaseClass and DerivedClass which is deriving publicly. Now i'm having overloaded operator methods in class BaseClass wh...
Summary: 1. C++ only defines normal operators for regular data types like float, int and char. Without operator overloading the following is undefined because the operators “>>” “<<” are not defi...