[prog] C++, global function with optional arguments

Sue Stones suzo at bigpond.net.au
Sat Apr 19 23:23:26 EST 2003


Further experimentation gave me the answer, I needed to remove the default  
values from the function header.

thanks 

sue


On Sat, 19 Apr 2003 10:25 pm, Sue Stones wrote:
> I have written a golbal function with the following declaration
> void trim (char str[], int left = 1, int right = 1);
>
> It removes leading and trailing whitespace, if left and right, resectively,
> are true.
>
>
> When I have the function present without a separate declaration it works
> Ok, but when I remebered that I needed the function deaclaration as well as
> the function itself I got the following errors.
>
>
> g++     trim.C   -o trim
> trim.C: In function `void trim(char*, int, int)':
> trim.C:23: default argument given for parameter 2 of `void trim(char*, int
> = 1, int = 1)'
> trim.C:18: after previous specification in `void trim(char*, int =1, int
> =1)' trim.C:23: default argument given for parameter 3 of `void trim(char*,
> int = 1, int = 1)'
> trim.C:18: after previous specification in `void trim(char*, int =1, int
> =1)' make: *** [trim] Error 1
> [
>
> Do you know what I am doing wrong?
> sue
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming



More information about the Programming mailing list