Muokkaa

Jaa


Compiler Error C3365

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

An attempt was made to compose delegates with different types. See How to: Define and Use Delegates (C++/CLI) for more information about delegates.

Example

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();
}