what does it mean when you say z=1? Does it ignore what value you pass into the function? What is this called?
That is a default value for z. Thus, you can call the function with just two arguments, and z will be assigned the value 1. If a third argument is passed to the function, z will be assigned that value.
aah thanks, so it's kinda of like overloading without actually overloading!
Actually it is not function overloading. In Function overloading the return type and argument type is often different. It is more versatile and a different defination(i.e. different sets of instruction for same function) is been called.
Wherein in the default argument, only one defination is there. The default argument are optional.If they are not specified,the compiler specifies them by default.
Remember all the default argument should be placed from right. i.e. func(int x, int z=1, int y) is not allowed. int z=1 should be on the right.
I think he understands that. In use, however, there is no semantic difference.