Can the result of a function call be used as a default parameter value?

c++, default-value, parameters

Solution

Go figure! It does work. Default arguments in C++ functions

Problem

Is there a good method for writing C / C++ function headers with default parameters that are function calls? I have some header with the function: ``` int foo(int x, int y = 0); ``` I am working in a large code base where many functions call this function and depend on this default value. This default value now needs to change to something dynamic and I am looking for a way to do: ``` int foo(int x, int y = bar()); ``` Where bar() is some function that generates the default value based on some system parameters. Alternatively this function prototype would look like: ``` int foo(int x, int y = baz.bar()); ``` Where baz is a function belonging to an object that has not been instantiated within the header file.

Original source