RAD Studio
ContentsIndex
PreviousUpNext
E2158: Operand of 'delete' must be non-const pointer (C++)

It is illegal to delete a variable that is not a pointer. It is also illegal to delete a pointer to a constant. 

For example:

const int x=10;
   const int * a = &x;
   int * const b = new int;
   int &c = *b;
   delete a;   //illegal - deleting pointer to constant
   delete b;   //legal
   delete c;   //illegal - operand not of pointer type
               //should use 'delete&c' instead
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!