RSS
Follow Us
Contribute
 
 
 
 

Error C2541: (delete) : delete : cannot delete objects that are not pointers

 
We need YOUR SKILLS in this collaborative work, to build the largest solution center for error messages.

From $1

Table of contents
  1. 1. Cause
  2. 2. Solution
  3. 3. About This Article

Cause

The delete operator was used on an object that is not a pointer. Ex:

int main() {
   int i;
   delete i;   // C2541 
}

Solution

Possible resolution:

int main() {
   int *ip = new int;
   delete ip;
}

About This Article

This article is a derivative work based on Compiler Error C2541 which is provided by MSDN Community Content - Visual C++.

 
 
 
 
Comments