Export (0) Print
Expand All
Expand Minimize

Compiler Error C3365

Error Message

operator 'operator' : differing operands of type 'type1' and 'type2'

An attempt was made to compose delegates with different types. See How to: Compose Delegates for more information about delegates.

The following sample generates C3365:

// C3365.cpp
// compile with: /clr
delegate void D1();
delegate void D2(int);

ref class R {
public:
   void f(){}
   void g(int){}
};

int main() {
   D1^ d1 = gcnew D1(gcnew R, &R::f);
   D2^ d2 = gcnew D2(gcnew R, &R::g);
   D1^ d3 = gcnew D1(gcnew R, &R::f);

   d1 += d2;   // C3365
   d1 += d3;   // OK
   d1();
}

Community Additions

ADD
Show:
© 2014 Microsoft