Here is the code in c++.
class A {
private:
A() {};
void xx_func() {}
void yy_func() {}
public:
~A() {};
static A &GetInstance() {
static A a_ins;
return a_ins;
}
static void func1() {
A::GetInstance().xx_func();
// other code
}
static void func2() {
A::GetInstance().yy_func();
//other code
}
};
The GetInstance
function return a local static variable. Is it safe for func1
、 func2
to call A::GetInstance()
?
Aucun commentaire:
Enregistrer un commentaire