开发者

Error C3918: Error wile checking event for being nullptr

开发者 https://www.devze.com 2023-03-06 19:00 出处:网络
I have delegate and event in my .h file delegate void ResponseReceivedHandler(System::Object^ sender, WhoisEventArgs^ e);

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 ?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消