Hi,
I would like to write a member function with a default argument,
but the value of the default argument I would like to use is the value
of the classes data member
class testdf
{// testdf
private:
const int _defaultVal;
public:
testdf() : _defaultVal(1) {}
int testMF(int arg = _defaultVal){ return arg; }
~testdf();
}; // testdf
The compiler plainly doesn't allow this. But it seems like a
pretty legitimate usage, so I was wondering if there was some workaround for this?
The compiler error message says that the datamember needs to be static, and if
I switch it to static it does work.