Tuesday 1 July 2014

Compare default arguments and function overloading.




Compare default arguments and function overloading.


In C++ with the default arguments , the default values can be provided in the function prototype itself and the that function can be called even if the arguments are missing.
But there is one thing that should be considered that is , if you want to default a middle argument then all the arguments on its right must be defaulted.

And on the other side of this , you can overload a function for all possible argument combinations . It basically overcomes the limitation of default arguments but also the compiler is saved from the problem of testing the default value and pushing it on the function call stack. So with that compiler can process another thing.

No comments:

Post a Comment