Operator Overloading Concept
What is the Operator Overloading Concept?
Answers
C++ allows you to specify more than one definition for a function name or anoperator in the same scope, which is called function overloading andoperator overloading respectively.
An overloaded declaration is a declaration that had been declared with the same name as a previously declared declaration in the same scope, except that both declarations have different arguments and obviously different definition (implementation).
When you call an overloaded function or operator, the compiler determines the most appropriate definition to use by comparing the argument types you used to call the function or operator with the parameter types specified in the definitions. The process of selecting the most appropriate overloaded function or operator is called overload resolution.
Function overloading in C++:You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You can not overload function declarations that differ only by return type.
Operator Overloading Concept:
Explanation:
- The overloading is a term that means that one thing can be use used for more than one work.
- The operator overloading states the concept that any operator is used for single work.
- For example, the '+' operator is used for the addition of two numbers and for the concatenation of the two string.
- Here we saw that the '+' operator is used for two work, hence we can say that the '+' operator is overloaded.
- Any user can modify any operator to do the other work using this concept.
Learn More :
- Operator Overloading : https://brainly.in/question/8894024