Nóta
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as shíniú isteach nó eolairí a athrú.
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as eolairí a athrú.
incompatible event 'function1' and handler 'function2'; event source and event handler must be the same type
Remarks
The event source and event receiver must have the same type (for example native vs. com types). To fix this error, make the types of the event source and the event handler match.
Example
The following example generates C3731:
// C3731.cpp
// compile with: /clr
#using <mscorlib.dll>
[event_source(native)]
struct A {
__event void MyEvent();
};
[event_receiver(managed)]
// try the following line instead
// [event_receiver(native)]
struct B {
void func();
B(A a) {
__hook(&A::MyEvent, &a, &B::func); // C3731
}
};
int main() {
}