The parameters in a function declaration can be assigned a default value as shown below: double area(double radius, double Pi = 3.14); We can declare multiple parameters with default values. But, all suck kind of parameters must be at the last of the parameters list. We can assign our custom value for the parameter as shown below: area(2.5, 3.1415); For the above function call, Pi value will be taken as 3.1415 instead of the default value 3.14. Following program demonstrates parameters with default values: 1 2 3 4 5 6 7 8 9 10 11 12 13
The post How to create Function Parameters with Default values in C++ appeared first on Coding Security.
How to create Function Parameters with Default values in C++
read more
Tidak ada komentar:
Posting Komentar