I wanted to know why the default value for a variable for a class method cannot be a non-stationary method or a member of the same class.
Is there a reason for this? Could the compiler give the method a position in the non-static default class?
I tried to quickly find the answer, but I could not find a good answer.
EDIT: here is an example.
It is legal:
class ClassTemp
{
static int s_member;
int MagicOperation(int defaultValue = s_member)
{
return defaultValue;
}
};
But this is not so:
class ClassTemp
{
int m_member;
int MagicOperation(int defaultValue = m_member)
{
return defaultValue;
}
};
source
share