J
John Doe
Hi,
I have a singleton class defined like this :
class UIManager : public CSingleton<UIManager>,
public CObject
{
protected:
DECLARE_DYNAMIC(UIManager)
friend class CSingleton<UIManager>;
UIManager();
virtual ~UIManager();
public:
....
};
and I was using this code like this :
A)
UIManager* l_pUiMgr = UIManager::GetInstance();
ASSERT (l_pUiMgr != NULL);
l_pUiMgr->GetResText( a_ResId, bStripHtml);
But I was fed up with always typing this so I have declared below my
UIManager class a static function :
static inline UIManager& UIManager() { return *(UIManager::GetInstance()); }
and I wanted to be able to call it like that :
UIManager().GetResText( a_ResId, bStripHtml);
The problem is I get some compilations errors with the code in A)
5>c:\wce_v42\inc\BaseView.h(227) : error C2065: 'l_pUiMgr' : undeclared
identifier
Why I cannot write UIManager* now ?
I have a singleton class defined like this :
class UIManager : public CSingleton<UIManager>,
public CObject
{
protected:
DECLARE_DYNAMIC(UIManager)
friend class CSingleton<UIManager>;
UIManager();
virtual ~UIManager();
public:
....
};
and I was using this code like this :
A)
UIManager* l_pUiMgr = UIManager::GetInstance();
ASSERT (l_pUiMgr != NULL);
l_pUiMgr->GetResText( a_ResId, bStripHtml);
But I was fed up with always typing this so I have declared below my
UIManager class a static function :
static inline UIManager& UIManager() { return *(UIManager::GetInstance()); }
and I wanted to be able to call it like that :
UIManager().GetResText( a_ResId, bStripHtml);
The problem is I get some compilations errors with the code in A)
5>c:\wce_v42\inc\BaseView.h(227) : error C2065: 'l_pUiMgr' : undeclared
identifier
Why I cannot write UIManager* now ?