Describe how to overload various operators.

CMPTR
3rd Edition
ISBN:9781337681872
Author:PINARD
Publisher:PINARD
Chapter20: Creating A Presentation
Section: Chapter Questions
Problem 2QY
icon
Related questions
Question

Describe how to overload various operators.

Expert Solution
Step 1: Note

Operator overloading is explained below with C++ programming language.

Step 2: Definition

Operator overloading:

Operator overloading refers to the use of an operator to produce “2” or more meanings to it.

Restrictions on Operator overloading:

  • Not all operators can be overloaded. Only specific set of operators can be overloaded.
  • Precedence of the operator is not able to be changed on overloading.

Syntax to overload the operator:

returntype class_name :: Operator operator_symbol(arguments)

{

    //Function body

}

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer