Suppose I have the following class:
class A {
private:
static double X;
};
double A::X = 0.0;
The variable A::Xreally needs to be static, because all instances Amust use the same value in the context in which I deal A::X.
Now, my question is whether to do getter and setter functions for A::Xstatic. They will be defined as follows:
void A::setValue(const double x) {
#pragma omp critical
{
if(x<0.0||x>1.0)
X = x;
}
}
double A::getValue() {
#pragma omp critical
{
return X;
}
}
It seems to me that it has absolutely no practical significance whether these functions getter and setter are added to Aas static or non-static member functions. Is it correct?
, , , getter setter , ?