functions

closed account (9605fSEw)
What happens when a function is called with only one parameter but it is decleared such as it shud be called with 3 parameters or arguments...?
The simple answer is that the compiler will flag it as an error.

However, you also have the option when declaring a function of using defualt values for parameters. The restriction on this is that if a default is supplied for a parameter, all parameters to the right of that must also have defaults supplied.

so if you declared

int myFunction(int a, int b=5, int c=7);

the following are all legal

1
2
3
myFunction(5);    // = myFunction(5,5,7)
myFunction(2,3); // = myFunction(2,3,7)
myFunction(6,2,12);



Topic archived. No new replies allowed.