void volume(int l=10, int w=10, int h=10);
int main()
{
clrscr();
volume(); //equivalent to volume(10,10,10)
volume(5); //equivalent to volume(5,10,10)
volume(8,6); //equivalent to volume(8,6,10)
volume(6,7,8);
getch();
return 0;
}
void volume(int l, int w, int h)
{
cout<<"volume = "<<l*w*h<<endl;
}
so now my question is that we are using pass by value then why the value assign when we call the method with empty parameter and the value assignd to the variable got the place. and when we pass other value it does not generate any error.
Because the language is designed to work like that!
Or are you asking how the compiler makes it work?
The standard does not specify how it should work just that it should.
But potentially one solution would be to generate four methods behind the scenes:
Or the compiler could inject tha parameters at the call site: