description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||
---|---|---|---|---|---|---|---|
Learn more about: Compiler Error C3898 |
Compiler Error C3898 |
11/04/2016 |
|
|
d9a90df6-87e4-4fe7-ab01-c226ee86bf10 |
'var' : type data members can only be members of managed types
An initonly data member was declared in a native class. An initonly
data member can only be declared in a CLR class.
The following sample generates C3898:
// C3898.cpp
// compile with: /clr
struct Y1 {
initonly
static int data_var = 9; // C3898
};
Possible resolution:
// C3898b.cpp
// compile with: /clr /c
ref struct Y1 {
initonly
static int data_var = 9;
};