This code compiles and works the way I want it, but why?
#include <iostream>
class Test {
private:
static bool _inited;
static bool _init() {
std::cout << "init!" << std::endl;
return true;
}
};
bool Test::_inited = Test::_init();
int main(int argc, char** argv) {
}
And if I make what I think is a unrelated change:
bool _inited = Test::_init();
it no longer compiles, giving me the expected error about trying to call a private method.