K
k.w.
The FAQ gives the following example:
Fred& x()
{
static Fred* ans = new Fred();
return *ans;
}
My question is:
What will happen if this function is called more than once?
Will a new object be created?
Will new memory be allocated?
Will the memory for the first object be leaked? (we no longer have pointer
to it)
Fred& x()
{
static Fred* ans = new Fred();
return *ans;
}
My question is:
What will happen if this function is called more than once?
Will a new object be created?
Will new memory be allocated?
Will the memory for the first object be leaked? (we no longer have pointer
to it)