Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default parameters

Status
Not open for further replies.

foxmuldr3

Programmer
Jul 19, 2012
160
0
0
US
Does C++ have a way to pass in the default parameter without specifying it? Example:

Code:
bool debug_log(char* text, int length, bool lLogAlways = true, SRgb* backColor = NULL, SRgb* foreColor = NULL);

#define debug_log_error(a, b) debug_log(a, b, true, &redColor, &whiteColor)

If I use debug_log_error("Hi", 2) it will use the true there for parameter 3, but if I later change my function definition to use false for the lLogAlways parameter, then unless I remember to change my debug_log_error #define as well, it will now be stale and out of sync.

If I could leave the parameter blank, or use an @ there (or something), to tell the compiler to fill it in with the default value ... that would be what's needed.

Is there a way?

--
Rick C. Hodgin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top