What is operator overloading in C++?
In this C++ interview questions, we will learn about:
What is Operator Overloading in C++?
Operator overloading is a type of polymorphism that gives C++ ability to the operator with preference to data type and have user-defined meaning to it.
Example: using '+' operator, two strings can be concatenated.
Properties of Operator Overloading
The overloaded operator has a return type and parameter list.
Operations happened over user-defined data types.
In this feature, C++ allows programmers to redefine the meaning of operator.
Syntax of operator overloading in c++
Return_type class :: operator
Operator Overloading can be done by implementing on this type of functions:
member/non-member functions and
Example of operator overloading in c++
Operator overloading in c++ example is given below:
/* Program of operator overloading for Unary Minus operator */
using namespace std;
unsigned int c;
void operator -()
The operators that are not overloaded:
scope resolution operator(::)
Would you like to see your article here on tutorialsinhand.
program by tutorialsinhand.com
About the Author
Page Views :
Published Date :