Compiler Error C2845
Collapse the table of content
Expand the table of content
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. ArchiveDisclaimer

Compiler Error C2845

'operator' : pointer arithmetic not allowed on this type

You cannot increment the pointer to a managed class.

Managed Extensions for C++

You cannot increment the pointer to a __gc class. Also, string operators are only valid with /clr (not /clr:oldSyntax).

The following sample generates C2845:

// C2845b.cpp
// compile with: /clr:oldSyntax
using namespace System;
__gc class X {};

int main() {
   X *pX = new X;
   pX++;   // C2845

   String * a = new String("abc");
   String * b = new String("def");
   Console::WriteLine(a + b);   // C2845 not with /clr:oldSyntax
© 2015 Microsoft