Expand Minimize
2 out of 2 rated this helpful - Rate this topic

Compiler Error C3222

Error Message

'parameter' : cannot declare default arguments for member functions of a managed type or generic functions

It is not permitted to declare a method parameter with a default argument. An overloaded form of the method is one way to work around this issue. That is, define a method with the same name with no parameters and then initialize the variable in the method body.

The following sample generates C3222:

// C3222_2.cpp
// compile with: /clr
public ref class G {
   void f( int n = 0 );   // C3222
};

The following sample generates C3222:

// C3222.cpp
// compile with: /clr:oldSyntax
public __gc class G {
   void f( int n = 0 );   // C3222
};
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.