Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 16 Online
OpenStudy (anonymous):

Can someone tell me an easier definition of overloaded operators?

OpenStudy (harsha19111999):

While programming, it is possible to define two or more operators within the same class that contain the same name, as long as their parametric declarations are not same. So, the operators are said to be overloaded operators

OpenStudy (mandre):

You use overloaded operators when you create your own types/classes and you want to apply existing operators to your class. Example: If you create the class Animal and you have the following code: Animal dog1; Animal dog2; dog1.breed = "Chihuahua"; dog1.color = "Brown"; dog2 = dog1; //Use 'operator=' to overload the = operator to transfer the properties of dog1 to dog 2. After the last line dog2.breed = "Chihuahua" and dog2.color = "Brown". Of course you will have to write code for 'operator=' to tell it what to do when you use "=".

OpenStudy (anonymous):

In simple terms, you are loading the operator with more actions than default action. For e.g., by default + is used to add 2 numbers and you could make it to add 2 strings. Now, you could say + is an overloaded operator.

OpenStudy (anonymous):

An overloaded operator is simply an operator (e.g. "+") which has different meaning depending on the context it is used in. by example: "+" means addition when you use it as mathematical operator: 5 + 7 "+" means concatenation when you use it to join to stings: "This is an " + "overloaded operator"

OpenStudy (anonymous):

when the same operator can be used with variables of different type it is said that it is overloaded

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!