नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'event handler': an event handler method must have the same storage class as the source 'event'
Remarks
An event has a different storage class than the event handler to which it is hooked. For example, this error occurs if the event handler is a static member function and the event is not static. To fix this error, give the event and the event handler the same storage class.
Example
The following example generates C3703:
// C3703.cpp
// C3703 expected
#include <stdio.h>
[event_source(type=native)]
class CEventSrc {
public:
__event static void MyEvent();
};
[event_receiver(type=native)]
class CEventHandler {
public:
// delete the following line to resolve
void MyHandler() {}
// try the following line instead
// static void MyHandler() {}
void HookIt(CEventSrc* pSource) {
__hook(CEventSrc::MyEvent, pSource, &CEventHandler::MyHandler);
}
void UnhookIt(CEventSrc* pSource) {
__unhook(CEventSrc::MyEvent, pSource, &CEventHandler::MyHandler);
}
};
int main() {
CEventSrc src;
CEventHandler hnd;
hnd.HookIt(&src);
__raise src.MyEvent();
hnd.UnhookIt(&src);
}