Explain the rules for overloading an operator, C/C++ Programming

Assignment Help:

Rules for overloading an operator

This summarizes the most significant points you need to know in order to do operator function overloading.

  • The only operators you may overload are the ones from the C++ list and not all of those are available. You cannot arbitrarily choose a new symbol (such as @) and attempt to "overload it.
  • Start by declaring a function in the normal function fashion, but for the function name use the expression:

                   Operator op

   Where op is the operator to be overloaded. You may leave one or more spaces before op.

  • The pre-defined precedence rules cannot be altered. i.e. you cannot, for instance, make binary '+' have higher precedence than binary '*'. In addition, you cannot alter the associativity of the operators.

 


Related Discussions:- Explain the rules for overloading an operator

HASHING, What is meant by open addressing? Explain various collision resolu...

What is meant by open addressing? Explain various collision resolution techniques with example

Create a program that converts numbers to characters, People sometimes give...

People sometimes give their phone numbers using one or more alphabetic characters. Create a program that converts the alphabetic characters to their corresponding numbers. For exam

Explain the switch construct, The Switch Construct The switch statement...

The Switch Construct The switch statement is a multi-way decision-making construct that tests an expression matches one of a number of constant values, and branches accordingly

CarDealership, ABC Car Dealership needs your help to update the ordering sy...

ABC Car Dealership needs your help to update the ordering system. This car dealer is selling four types of vehicles: Sedan, Truck, SUV, and mini Van. And each type of vehicle can h

Constructors and destructors, Constructors and Destructors: A Class is ...

Constructors and Destructors: A Class is defined as constructor by declaring a constructor in the form of function inside the class.  In other word a function in the name of

Area under curve, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.   #include float start_poin

Write a program that finds the minimum total number of shelv, Write a progr...

Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

Last ant on rod, There are ''n'' ants on a ''n+1'' length rod. The ants are...

There are ''n'' ants on a ''n+1'' length rod. The ants are numbered from 1 to n and are initially placed at positions starting from position 1 till position n. They are moving eith

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd