Error C3918: Error wile checking event for being nullptr

你。 提交于 2019-12-11 04:23:46

问题


I have delegate and event in my .h file

delegate void ResponseReceivedHandler(System::Object^ sender, WhoisEventArgs^ e);
event ResponseReceivedHandler^ ResponseReceived; 

somewhere in my code I want to check if event is nullptr or no, but when I write

EDITED:

if (this->ResponseReceived != nullptr)
{
     this->ResponseReceived(this, e);
}

Error occurred

Error 1 error C3918: usage requires 'VT::WhoisClient::WhoisRequest::ResponseReceived' to be a data member c:\Users\ViToBrothers\Desktop\ViTo Projects\VT.WhoisClient\VT.WhoisClient\VT.WhoisRequest.cpp 50

What can I do ?


回答1:


I believe that in this case, the compiler is generating the accessor functions and backing storage for the event handler delegate. Thus, it is not necessary for you to check for null.

See more here: http://msdn.microsoft.com/en-us/library/4b612y2s.aspx



来源:https://stackoverflow.com/questions/6034720/error-c3918-error-wile-checking-event-for-being-nullptr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!