Export (0) Print
Expand All
Expand Minimize

Compiler Error C2844

'member' : cannot be a member of interface 'interface'

An interface class cannot contain a data member unless it is also a property.

Anything other than a property or member function is not allowed in an interface. Furthermore, constructors, destructors, and operators are not allowed.

The following sample generates C2844:

// C2844a.cpp
// compile with: /clr /c
public interface class IFace {
   int i;   // C2844
   // try the following line instead
   // property int Size;
};

The following sample generates C2844:

// C2844b.cpp
// compile with: /clr:oldSyntax /c
#using <mscorlib.dll>
__gc __interface IFace {
   int i;   // C2844
   // try the following line instead
   // __property int Size { get; set; };
};

Community Additions

ADD
Show:
© 2014 Microsoft