functions
Displaying 1-4 of 4 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
chanman

ok I have this function:

void fadeIn(int duration, int color, int image) {
//blah
}

can I make a default value for image for example:

void fadeIn(int duration, int color, int image = 0) {
//blah
}

so if the coder does not need to show an image, s/he can just call the function with the first 2 arguments?

eg. fadeIn( 500, RGB(255, 255, 255));

Posted on 2004-09-15 19:00:35 (last edited on 2004-09-15 19:05:03)

Zip

No. Pass a value, or write another function.

Zip

Posted on 2004-09-15 19:04:19

Zip

Moar useful answer

Zip

Posted on 2004-09-15 19:25:01

vecna

I'll elaborate a bit: Default parameters are tricky in verge because there's only two basic data types. As most functions just take a varying number of ints as arguments, its very difficult to be able to 'default' more than one arguement since you have no way of knowing which parameter is which.

I've always felt default arguements in most languages were a hackish construct anyway. SAS macro functions support default arguments, but when you call them you do %myfunc(arg1=foo arg2=barr), so its easy to know which arguements are actually being passed and which are being defaulted. Most c-like languages don't work that way. Overrides would be a more useful addition to VC, and is possible, but not a priority at this time.

Posted on 2004-09-16 05:16:16


Displaying 1-4 of 4 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.