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 derfloh 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
Joined
Jul 19, 2012
Messages
170
Location
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
 
C++ does not have this feature.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top