Monday, July 20, 2009

Construct on First Use Idiom

You need to control the evaluation order of static initialization.

This approach solved the problem.


static Fred& X()
{
static Fred* obj = new Fred();
return *obj;
}

No comments: