+ 1
Kindly explain with all code
the effect of a default argument can be alternativly achieved by overloading discuss with an example
3 Antworten
+ 2
You can leave out arguments with default value. And you can alternatively create overloads with and without that argument.
int plusTwo(int n=0){return n+2;}
---or---
int plusTwo(int n){return n+2;}
int plusTwo(){return plusTwo(0);}
In both cases you can call with or without argument:
plusTwo() returns 2
plusTwo(0) returns 2
+ 1
Which code, what language? To whom explain?
0
Please tag a relevant language name to clarify context. You are taking multiple classes it is not possible to deduce language context without one specified in the tags ☝
Some programming languages does not support default argument in functions e.g. Java.