(C++) delete a pointer-to-const

February 24, 2017 · View on GitHub

 

 

 

 

 

(C++) delete a pointer-to-const

 

Be aware that you can delete a pointer-to-const:

 


int main() {   //Create a read-only MyClass   const MyClass * const myClass = new MyClass;   delete myClass; //VALID C++ CODE! }

 

See exercise #2: a foolproof function for the implications and prevention of this.