CListCtrl *ctl;
ctl=&GetListCtrl();
这个语句有什么错误么。为什么会有这样的错误提示呢
'GetListCtrl' : undeclared identifier
error C2440: '=' : cannot convert from 'int *' to 'class CListCtrl *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
ctl=&GetListCtrl();
这个语句有什么错误么。为什么会有这样的错误提示呢
'GetListCtrl' : undeclared identifier
error C2440: '=' : cannot convert from 'int *' to 'class CListCtrl *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
CListCtrl& GetListCtrl( ) const;
它返回的本来就是指针了啊,你没有必要在去加那个引用符号的,改成这样看看:
ctl=GetListCtrl();
ctl=&(GetListCtrl());
CListCtrl *ctl;
ctl=&GetListCtrl();//所以就没有必要了.
建议还是使用
CListCtrl & ctrl = GetListCtrl();
这样可以避免判断ctl是否为空,
如果为空,则使用时会失败.