How can I initialize an CListBox& null reference ?
-
I want to ask you something ( maybe ) simple question : Can I initialize an CListBox& ListCtrl reference with null value ? Because later , I want to use ListCtrl reference variable in many if contitions ... I try :
CListBox& ListCtrl = NULL;
and doesn't go ... Give me an error like this :
initializing' : cannot convert from 'const int' to 'class CListBox &'
-
I want to ask you something ( maybe ) simple question : Can I initialize an CListBox& ListCtrl reference with null value ? Because later , I want to use ListCtrl reference variable in many if contitions ... I try :
CListBox& ListCtrl = NULL;
and doesn't go ... Give me an error like this :
initializing' : cannot convert from 'const int' to 'class CListBox &'
Hi, You are trying to initialize a reference to CListBox, in which case you need to give proper object. NULL is nothing but a typedef of '0'. To solve your problem try to use a pointer variable instead of reference variable. CListBox *pListBox = NULL;
-
Hi, You are trying to initialize a reference to CListBox, in which case you need to give proper object. NULL is nothing but a typedef of '0'. To solve your problem try to use a pointer variable instead of reference variable. CListBox *pListBox = NULL;
I can use CListBox* pList = NULL; Why , because somewhere I have :
CListBox& GetListBoxCtrl() const {return *(CListBox*)this;}
How can I solve the problem ?
-
I can use CListBox* pList = NULL; Why , because somewhere I have :
CListBox& GetListBoxCtrl() const {return *(CListBox*)this;}
How can I solve the problem ?
You cannot assign NULL to a reference. In your case you can do this -
CListBox* pListBox = &GetListBoxCtrl();
«_Superman_» _I love work. It gives me something to do between weekends.
-
I want to ask you something ( maybe ) simple question : Can I initialize an CListBox& ListCtrl reference with null value ? Because later , I want to use ListCtrl reference variable in many if contitions ... I try :
CListBox& ListCtrl = NULL;
and doesn't go ... Give me an error like this :
initializing' : cannot convert from 'const int' to 'class CListBox &'
Nope. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I want to ask you something ( maybe ) simple question : Can I initialize an CListBox& ListCtrl reference with null value ? Because later , I want to use ListCtrl reference variable in many if contitions ... I try :
CListBox& ListCtrl = NULL;
and doesn't go ... Give me an error like this :
initializing' : cannot convert from 'const int' to 'class CListBox &'
C++ basics would help.
...byte till it megahertz... my donation to web rubbish