My class has a static creator function that will instantiate and initialize
an object. The initialization requires access to private members. Is there
a way to define a class' own static member function as a friend to that class?
class CMyClass
{
public:
static CMyClass *Create(int someValInit);
private:
int m_SomeVal;
};
CMyClass *CMyClass::Create(int someValInit)
{
// simplified sample
// my implementation using ATL CComObjectRootEx,
// and object creation is via CComObject::CreateInstance
// which can only use default ctor
CMyClass *pRet = new CMyClass;
pRet->m-SomeVal = someValInit;
return pRet;
}