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

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) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!