L
laikon
Hi, everyone, below is my program to test static pointer data member;
class A
{
private:
static A* p;
protected:
A() {}
public:
static A* init()
{
p = new A();
}
};
A* A:= NULL;
int main()
{
A* a = A::init();
}
so the problem is memory allocated by init for p is leaked after
function main exit, then where is the proper place to release memory of
the static pointer data member?
class A
{
private:
static A* p;
protected:
A() {}
public:
static A* init()
{
p = new A();
}
};
A* A:= NULL;
int main()
{
A* a = A::init();
}
so the problem is memory allocated by init for p is leaked after
function main exit, then where is the proper place to release memory of
the static pointer data member?