added structure overview sentence of ways to overload (#27345)
This commit is contained in:
committed by
Christopher McCormack
parent
91f4865ab4
commit
9741e64f21
@ -6,10 +6,10 @@ C++ allows you to specify more than one definition for a function name or an ope
|
||||
|
||||
An overloaded declaration is a declaration that is 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 have 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.
|
||||
When you call an overloaded function or operator, the compiler determines the most appropriate definition to use, by comparing the argument types you have 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. Generally, the most common ways to overload in C++ are function overloading, operator overloading, and overloading on const.
|
||||
|
||||
### 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 cannot overload function declarations that differ only by return type.
|
||||
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 cannot overload function declarations that differ only by return type.
|
||||
|
||||
Following is the example where same function print() is being used to print different data types −
|
||||
|
||||
|
Reference in New Issue
Block a user