Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between operator overloading and operator overriding in C++?

Tags:

c++

What is the main difference between operator overloading and operator overriding in C++?

like image 695
bunty Avatar asked Sep 27 '10 12:09

bunty


1 Answers

Some use the latter term to describe what's being done when you defined an own global operator new or operator delete. That's because your own definition can replace the default version in the library. The C++ Standard uses the words replaces and displaces for this. Using "override" is a bit confusing because that term is already used for virtual functions being overridden by a function in a derived class.

The term "overloading" is the general term used for defining your own operator functions. This term is used even if no actual overloading happens by the operator function. One way to approach this term is because it "overloads" the built-in meaning of certain operators.

like image 82
Johannes Schaub - litb Avatar answered Nov 15 '22 21:11

Johannes Schaub - litb