[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA: SPICE GUI
> I haven't looked at the code, but I'm guessing that Mike compiled on gcc
> 2.96 or similar. This allowed a default argument for a function param to
> be set both in the function's declaration and definition. This isn't
> kosher C++, and gcc 3+ fixed it, so it can be specified in either the
> decln or the defn., but not both.
This was my thought as well.
> You'll need to edit out all the defaults in one or the other. I prefer to
> keep them in the definition, for documentation, but this can cause
> problems (I forget what) so they're probably best kept in the
> declaration, in the header file.
If you put them in the header, the default will be applied to all callers.
If you put it in the definition (in the .cpp file), then only callers in
the .cpp file will get access to the default. This is because the default
is applied at compile time, and the contents of the .cpp file are only
visible to the compiler while it is compiling the .cpp file since you don't
#include the .cpp file elsewhere.
In g++ 2.95.x (and below) if you specify different defaults in both places
you can have different defaults applied depending on where you're calling
from. Confusing at best ;-)
The upshot is that you should probably always define defaults in the header
(as Evan said.) And remember that specifying defaults does not impact the
signature with respect to hiding or overloading...
Take care,
Dale
--
Dale E. Martin, Clifton Labs, Inc.
Senior Computer Engineer
dmartin@cliftonlabs.com
http://www.cliftonlabs.com
pgp key available