473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

oops

concepts of overloding operators with an example
Sep 9 '09 #1
2 1166
weaknessforcats
9,208 Expert Mod 8TB
Use the Internet to research this.

The idea is to make yout code easy to use. If you have x + 10 and x is an int then 10 is added to the int value. If x is a date, then 10 days would be added to the date value.

Unfortunately, the + does not work with dates. So, the overload is your implementation of the + operator for use with date variables.

Truly, the Internet has a ton of info on this.
Sep 9 '09 #2
manjuks
72
Hi,

Assume that you wants to add two strings (concatenate) say S1 and S2 like below

S = S1 + S2

But its not possible since + doesn't add strings, So you need to overload + operator to add (concatenate) the strings.

This is just an example to understand when you need to overload operators.

Thanks,
Manjunath
Sep 10 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Vaishali | last post by:
How is Object Oriented Programming implemented in .NET?
3
by: Robert Nolan | last post by:
This subject is probably simple to the readers, but I must be having one hell of a mental block cause I am beating my head against a wall. I need to create a simple folder tree that is about 3...
58
by: Jeff_Relf | last post by:
Hi Tom, You showed: << private const string PHONE_LIST = "495.1000__424.1111___(206)564-5555_1.800.325.3333"; static void Main( string args ) { foreach (string phoneNumber in Regex.Split...
34
by: Pmb | last post by:
Hi. I'm new to this group. I'm refreshing/learning C++ and am starting to learn Object Oriented Programming (OOP). In discussing this with people I came up short as to what the benefits of OOP are....
1
by: Jimnbigd | last post by:
Oops -- and I don't mean Object Oriented. I replied to several messages using "top posting". I ask the group to please accept my apology. I just found the FAQ on...
1
by: Jim | last post by:
Hello... I have just completed chapters 1-9 of Jessie's Learning C#. Great tutorial! But, talk about method overloading, I'm overloaded with OOPs! Can someone offer me some advise, please? I...
2
by: shrini | last post by:
Friends. I i am reading on pgp 5 oops. it is very interesting. But, in books i found only some chunks of code. I need a simple applicaion based on php5 oops. can you suggest me one?
4
by: Alan Edmund | last post by:
Hello, I am trying to make use of the following: function checkIt(){ if (document.PRODADD.AttributeValue.value == "") { //validate month select alert("Please select an option!");...
6
by: Demitrius >I | last post by:
Hi, I need a way to "push" a web page to a viewer (or viewers) on my web site. What I'm trying to do is conduct an online presentation, so I need to control what the viewers see and when they...
1
by: moreshwar | last post by:
Hi, I am working in software field from last 7 yrs basically on Turbo C, assembly. I recently switch over to .Net Programming. I want to understand first OOPS concept as i am totally unaware about...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.