Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error C3160

Error Message

'pointer' : a data member of a managed class cannot have this type

Interior garbage collection pointers may point to the interior of a managed class. Because they are slower than whole-object pointers and require special handling by the garbage collector, you cannot declare interior managed pointers as members of a class.

The following sample generates C3160:

// C3160.cpp
// compile with: /clr
ref struct A {
   // cannot create interior pointers inside a class
   interior_ptr<int> pg;   // C3160
   int g;   // OK
   int* pg2;   // OK
};

int main() {
   interior_ptr<int> pg2;   // OK
}

Managed Extensions for C++

The following sample generates C3160:

// C3160b.cpp
// compile with: /clr:oldSyntax

__gc struct A {
   // cannot create interior pointers inside a class
   int __gc* pg; // C3160
   int g;   // OK
   int __nogc *pg2;   // OK
};

int main() {
   int __gc* pg2;   // OK
}

Community Additions

ADD
Show:
© 2015 Microsoft