VC6 - deleting const char*
Posted on 2006-03-22
Is the following behaviour is also because the VC6 does no compy to the latest C++ standards (pro 1998)....
const char* ptr = new char[SIZE];
delete ptr; // compiler error...
error C2665: 'delete' : none of the 2 overloads can convert parameter 1 from type 'const char *'
Error executing cl.exe.
does always I have to typecast the pointer and then delete the variable...... as..
delete const_cast<char*> (ptr);
PS: I know the code given above doesn't make sense as such because you can't change the data afterwards.... but there might be scenario where some allocation function returns you const char* and the function does not take the ownership...