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

Virtual constructor, Is it possible to have Virtual Constructor? If yes, ho...

Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible?

Linear iterative process, (a) Write a recursive procedure (digits n) that c...

(a) Write a recursive procedure (digits n) that computes the number of digits in the integer n using a linear recursive process. For example, (digits 42) should return 2 and (digit

Super ansii prgm, Ask quIn the Byteland country a string "s" is said to sup...

Ask quIn the Byteland country a string "s" is said to super ascii string if and only if count of each charecter in the string is equal to its ascci value in the byteland country as

Functions, differentiate between inbuilt and user defined functions

differentiate between inbuilt and user defined functions

Minimum shelf, At a shop of marbles, packs of marbles are prepared. Packets...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Homework, 5 questions. plus i will provide the "vector.h" for the questions...

5 questions. plus i will provide the "vector.h" for the questions that needs it

Dynamic initialization of objects and dynamic constructor, Dynamic Initiali...

Dynamic Initialization of objects: It is initializing the objects by passing the valued to the constructor from the user input or other means.   Through cin operator a value

Calculate and display the marks and grade for each student, In this assignm...

In this assignment you are required to develop a program that allows the creation, viewing and storage of information about ITECH7603 Students. In order to complete the task you ha

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