Using Stata 13.1 SE on Windows 7, I'm having trouble with Mata classes: I can't seem to access static variables from static methods. For example, the following does not compile:
I receive the error "variable count undeclared". However, when I make test::increment() not static by removing the underlined word, it compiles. Am I doing something wrong? Shouldn't static methods be able to access static variables?
Code:
mata:
class example {
public:
static real scalar increment()
private:
static real scalar count
}
real scalar example::increment()
{
if (count == .)
count = 0
return(++count)
}
end
