Condividi tramite


Errore del compilatore C3711

'method': un metodo di origine evento non gestito deve restituire void o un tipo integrale

È stato definito un metodo nell'origine evento che non ha restituito void o un tipo integrale. Per correggere questo errore, rendere l'evento e il gestore eventi hanno un tipo restituito o void un tipo integrale, int ad esempio o long.

L'esempio seguente genera l'errore C3711:

// C3711.cpp
#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>

[event_source(native)]
class CEventSrc {
public:
   __event float event1();   // C3711
   // try the following line instead
   // __event int event1();
   // also change the handler, below
};

[event_receiver(native)]
class CEventRec {
public:
   float handler1() {         // change float to int
      return 0.0;             // change 0.0 to 0
   }
   void HookEvents(CEventSrc* pSrc) {
      __hook(CEventSrc::event1, pSrc, CEventRec::handler1);
   }
   void UnhookEvents(CEventSrc* pSrc) {
      __unhook(CEventSrc::event1, pSrc, CEventRec::handler1);
   }
};

int main() {
}