错误C3918:错误诡计检查事件是nullptr [英] Error C3918: Error wile checking event for being nullptr
问题描述
我有委托和事件在我.h文件中
I have delegate and event in my .h file
delegate void ResponseReceivedHandler(System::Object^ sender, WhoisEventArgs^ e);
event ResponseReceivedHandler^ ResponseReceived;
在某处我的code我想或者检查事件是 nullptr
没有,但是当我写
编辑:
if (this->ResponseReceived != nullptr)
{
this->ResponseReceived(this, e);
}
时发生错误
错误1错误C3918:使用需要 VT :: WhoisClient :: WhoisRequest :: ResponseReceived 是一个数据 成员C:\ Users \用户ViToBrothers \桌面\ VITO 项目\ VT.WhoisClient \ VT.WhoisClient \ VT.WhoisRequest.cpp 50
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
我该怎么办?
推荐答案
我认为,在这种情况下,编译器生成的存取功能和备份存储的事件处理程序委托。因此,没有必要为你检查空。
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.
详见这里: http://msdn.microsoft.com/en-美国/库/ 4b612y2s.aspx
这篇关于错误C3918:错误诡计检查事件是nullptr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!