What is the need for operator overloading?
Jigs28 0 Light Poster
Recommended Answers
Jump to PostIn other words, simplistically, it's a way to define what ==, <, >, etc are meant to be for a class that you define yourself.
Example, you have a class of CAR which contains
Make
Model
Year
PriceYou can define operator= to mean:
Same Make
Same Year
…
Jump to PostBut we can do these without overloading also.
Sure. We can make a function:
CAR AddTwoCars(CAR vehicle1, CAR vehicle2, CAR vehicleNew)
which 'adds' #1 & #2 and returns the new one. Or we can overload the + operator and have:vehicleNew = vehicle1 + vehicle2;
Java do not support …
Jump to PostOverloading an operator is overhead.
Only as much as any other function, not really a problem in general
Means in totality there is no actual use.
I'd disagree with this. You are correct in the sense that, since and operator is basically a function, it would always be possible to …
Jump to Post@WaltP:
i am not saying that if java does not support than c# should not. I mean to say is java has eliminated the concept of operator overloading and than too we don't need any operator overloading there.Nitpick: When did Java eliminate overloading? What version of Java took it …
All 13 Replies
thines01 401 Postaholic Team Colleague Featured Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Jigs28 0 Light Poster
thines01 401 Postaholic Team Colleague Featured Poster
Jigs28 0 Light Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
ravenous 266 Posting Pro in Training
Jigs28 0 Light Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Jigs28 0 Light Poster
thines01 401 Postaholic Team Colleague Featured Poster
Jigs28 0 Light Poster
thines01 401 Postaholic Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.