Unit 02
Unit 02
• These functions having the same name but different arguments are known as
overloaded functions.
For example:
// same name different arguments
int test() { }
int test(int a) { }
float test(double a) { }
int test(int a, double b) { }
Here,
• returnType is the return type of the function.
•the operator is a keyword.
• the symbol is the operator that we want to overload.
Like: +, <, -, ++, etc.
• arguments are the arguments passed to the function.
• The below operators are some built-in operators and these
operators are operates on built-in data types or primitive data
types available in C++. Like additions can be performed on
integer, float, and so on. If we are defining our own data type
like if we are writing a class Matrix.
• Can we overload all operators in C++?
• In C++, almost all operators can be overloaded except a few. Following is
the list of operators that cannot be overloaded in C++.
. (dot)
::
?:
sizeof
• Operator Overloading in Unary Operators (++, –)
• The increment operator ++ and decrement operator — are examples of
unary operators.