3 ms·
Sorry I read it again (the first time I was reading it on my phone) and I thought we were discussing about Meyers singleton: Singleton & theSingleton() { s
by pmelendez 14y ago
Sorry I read it again (the first time I was reading it on my phone) and I thought we were discussing about Meyers singleton:
Singleton & theSingleton() {
static Singleton instance;
return instance;
}
Which in the proper context is perfectly fine.
This is wrong:
class myclass {
// can have state
// ...
public static myclass m = new myclass(); // globally accessible static instance, which can have state
}
and the first link itself explain why.