Instead of trying to use a static const global or a member variable to provide the default argument, just use the appropriate constructor of the type:
Code:
class FilterClass { .. };
class A {
public:
A(FilterClass const& p_filter = FilterClass(..))
: filter(p_filter) { }
void action(FilterClass const& p_filter = FilterClass(..))
{
...
}
protected:
FilterClass filter;
};
Now, it may be your intention to use the member variable filter if no argument is provided to A::action(). In that case, overload A::action() such that the version with no arguments calls the version that takes a FilterClass by const reference. The version of A::action() that takes an argument would then not provide a default argument.
EDIT:
Better yet, define a free function named action in the same namespace as A:
Code:
void action(A& a, FilterClass const& filter)
{
a.action(filter);
}
EDIT:
Oh wait, I am not thinking correctly: the free function version is not applicable here. I was thinking of having a free function version that only takes an A by reference as the argument, but then you would not be able to provide the member variable as an argument.