---
title: "Operator overloading: need and definition"
subject: "Object Oriented Programming"
chapter: 5
key: "semester_3/object_oriented_programming:operator-overloading-why-define"
source: https://www.bctengineer.com/q/semester_3/object_oriented_programming/operator-overloading-why-define
site: BCT Engineering
---

# Operator overloading: need and definition

Object Oriented Programming · Chapter 5: Operator Overloading

- Asked in: 2074 Chaitra, 1 marks; 2072 Chaitra, 2 marks; 2069 Chaitra, 2 marks (asked 3 times)
- Video: [Operator Overloading Introduction | C++ Tutorial](https://www.youtube.com/watch?v=9tHu4mWtrnM) — Portfolio Courses
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_3/object_oriented_programming/operator-overloading-why-define
- Whole chapter: https://www.bctengineer.com/md/semester_3/object_oriented_programming/chapter-5

## Question

Define operator overloading. Why do we need operator overloading?

## Answer

**Operator overloading** is a feature of C++ that gives an existing operator (such as `+`, `-`, `==`, `<<`) an additional meaning for user-defined types (classes), while its original meaning for built-in types remains unchanged. It is done by writing a special function named `operator` followed by the operator symbol. It is a form of compile-time polymorphism.

**Why it is needed:**
- It lets objects of user-defined classes be used with the same natural notation as built-in types. For example, `c3 = c1 + c2;` for complex numbers or matrices is easier to read than `c3 = c1.add(c2);`.
- It makes programs shorter, more readable, and closer to mathematical notation.
- It makes user-defined types behave like built-in types (they can be added, compared, printed with `cout <<`).
- It increases extensibility, since a class can be used in expressions without changing the language.

Example: with `Complex operator+(Complex b)` defined, the statement `c = a + b;` adds the real and imaginary parts of two `Complex` objects.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is operator overloading?
   A. Giving an operator extra meaning for user-defined types, keeping its built-in meaning
   B. Creating new operator symbols
   C. Changing precedence
   D. Removing operators
   Answer: A. Existing operators are given additional meaning for classes. (Key point: Definition)

2. Why is it useful?
   A. Natural readable notation like c3 = c1 + c2
   B. Faster execution always
   C. Avoids classes
   D. Makes data public
   Answer: A. Objects can be used with the same natural notation as built-in types. (Key point: Purpose)

3. Operator overloading is a form of?
   A. Run-time polymorphism
   B. Compile-time polymorphism
   C. Inheritance
   D. Encapsulation
   Answer: B. It is resolved at compile time. (Key point: Polymorphism type)

## Related in Object Oriented Programming

- [Syntax of operator overloading](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Aoperator-overloading-syntax) — Object Oriented Programming, chapter 5, asked 4×
- [Disadvantage of operator overloading](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Aoperator-overloading-disadvantage) — Object Oriented Programming, chapter 5
- [Binary and unary operator overloading](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Abinary-unary-overloading) — Object Oriented Programming, chapter 5
- [City class with operator overloading](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Acity-class-operator-overload) — Object Oriented Programming, chapter 5
- [Need of template; function template overloading](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Awhy-template-function-overloading) — Object Oriented Programming, chapter 9
- [Function overloading; new/delete average program](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Afunction-overloading-new-delete-average) — Object Oriented Programming, chapter 3

## Related in other subjects

- [Why do we need DFT](https://www.bctengineer.com/question.md?key=semester_7%2Fdigital_signal_analysis_and_processing%3Awhy-need-dft) — Digital Signal Analysis and Processing, chapter 7, asked 6×
- [Why do we need FFT](https://www.bctengineer.com/question.md?key=semester_7%2Fdigital_signal_analysis_and_processing%3Awhy-need-fft) — Digital Signal Analysis and Processing, chapter 7, asked 2×
- [ADT of stack: value and operator definition](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aadt-stack-value-operator) — Data Structure and Algorithm, chapter 1
- [Transition curve: definition and need](https://www.bctengineer.com/question.md?key=semester_6%2Ftransportation_engineering_i%3Atc-objectives) — Transportation Engineering I, chapter 3, asked 6×
