Gary Wessle wrote:
I have a method with the last arguments having defaults like this
void filing(long, double,
const myType& r_mo=NULL,
const herType& r_tr=NULL);
is that acceptable, if not how is it done?
when I do the above, I get errors like
No, it is not reasonable to attempt to pass NULL for any parameter
declared a reference - a reference requires that the caller always
supply an object (of a suitable type) in order to call the function.
To indicate that values for myType and herType are not required in
order to call filing(), there are a few options available. One approach
is for filing to accept pointers instead of references for those
values:
void filing( long, double,
const myType* r_mo = NULL,
const herType* r_tr = NULL);
A better approach would probably be to overload filing() - with one
overload accepting the two reference parameters and another overload of
filing() that does not:
void filing( long, double, const myType& r_mo, const herType&);
void filing( long, double);
Greg