In: Computer Science
1)
Reference Parameter
The ref keyword is utilized to pass a argument as a kind of perspective or reference. This implies when estimation of that parameter is changed in the technique, it gets reflected in the calling. A argument that is passed utilizing a ref keyword must be instated in the calling before it is passed to the called method
Optional parameter
Method with a optional parameter can be called with just a portion of its parameter determined. Each optional parameter has a default an incentive as a feature of its definition. In the event that no argument is sent for as parameter, then the default value is utilized.
2)
Ambiguity may happen when the overload function, optional arguments is used. Ambiguity is showed in situations where the compiler doesn't know which of the overload function to call.
for example, lets consider a method that have 2 function with same name that is a method overloading.
Int samp(int p,int q = 5, int r = 9)
{
return p+q+r;
}
Int samp(int p, double q = 5.9, double r = 8.2)
{
return (int)(p + q +r);
}
In this example if we call the method samp with one argument ie, p .
such that,
int a;
a = samp(8);
Then the compiler will generate a error message