Is it possible to achieve such functionality, that parameter's value would default to another parameter's value if not specified?
Example:
class Health
{
public:
// If current is not specified, its value defaults to max's value
Health(int max, int current = max) : max_(max), current_(current) { }
int max_;
int current_;
};
As it is now, I am getting a compile error:
error: 'max' was not declared in this scope
Health(int max, int current = max) : max_(max), current_(current) { }
^