whats the difference....
int setDate(void)
void setDate(int)
whats the difference....
int setDate(void)
void setDate(int)
int setDate(void)
void setDate(int)
the difference my child is! that int setDate(void) returns to the calling function a integer but does not require any arguments thats why (void)-(However you could leave void out of the '()' becuase its unnessesary).
and void setDate(int) doesnt return anything but needs an integer as an argument.
this comes from some german geek. hahaha
>whats the difference....
>int setDate(void)
>void setDate(int)
My guess would be that the author wanted setDate to both set the date and return the current date if no new date is given:
I think it would be better to have the date returned and a default argument to determine if the date should be changed:Code:int setDate(void) { return date; } void setDate(int newDate) { date = newDate; }
Code:int setDate(int newDate=-1) { if (newDate != -1) date = newDate; return date; }
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.
don't confuse people with default arguments unless you're going to explain
>don't confuse people with default arguments unless you're going to explain
Default arguments aren't any more confusing than function overloading, which wasn't even touched on earlier in the thread. If you're going to criticize, at least do so fairly for everyone.
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.
I'd prefer Get/Set:or something that makes it look like a property:Code:int getDate() { return date; } void setDate(int newDate) { date = newDate; }I doubt you'd want to call a method setDate and have it actually get the date.Code:int Date() { return date; } void Date(int newDate) { date = newDate; }
SorryOriginally posted by Trauts
don't confuse people with default arguments unless you're going to explain