티스토리 뷰



Function Overloading 



Function overloading allows you to use the same function name for more than one definition in the same scope.


Function overloading has rules


first, it should have the same function name.


second, the number of arguments or the types should be different.

 




Example code






Result



When function 'func(4)' is called in main, function 'func(int a)' executed because it coincides with the type and the number of argument. And the same goes for func(int a, int b).



'C++' 카테고리의 다른 글

Class and Object in C++  (0) 2018.11.06
Dynamic Allocation in C++  (0) 2018.11.03
Call by reference & Call by value with example code  (0) 2018.11.03
Array and Pointer example  (0) 2018.10.31
Double pointer(pointer to pointer) basic example code  (0) 2018.10.31