lets say i make a function with 3 arguments:
myfunction (X,Y,Z);
in my program i call that function but i only need the middle argument. So would I write this:
myfunction (,5,) ?? because that gives me errors
Thanks for any help
lets say i make a function with 3 arguments:
myfunction (X,Y,Z);
in my program i call that function but i only need the middle argument. So would I write this:
myfunction (,5,) ?? because that gives me errors
Thanks for any help
No you can't. You have to pass all the arguments. If you find for some reason that you don't have to pass all the arguments then you most likely aren't using functions properly or you want a default value to take the missing arguments place.
thanks
To clarify: You don't have to specify all of the arguments, provided you have default values set in the prototype. However, you must provide all arguments to the left of the last argument you decide to specify.Originally posted by Polymorphic OOP
No you can't. You have to pass all the arguments. If you find for some reason that you don't have to pass all the arguments then you most likely aren't using functions properly or you want a default value to take the missing arguments place.
To illustrate:
void myfunction( int x = 0, int y = 1, int z = 2 );
myfunction( someVar, 10 ); // valid
myfunction( 20 ); // valid
myfunction( , 10, 0 ); // invalid
Quzah.
Hope is the first step on the road to disappointment.
Yeah, that's why i mentioned default. You are still passing a value to the function, however you are relying on the compiler to do it for you.
Nod. I just wanted to clarify how it worked in case they didn't know what a default argument was.Originally posted by Polymorphic OOP
Yeah, that's why i mentioned default. You are still passing a value to the function, however you are relying on the compiler to do it for you.
Quzah.
Hope is the first step on the road to disappointment.