I\'ve just noticed that the pointers passed to delete
can be const
qualified while those passed to free
cannot. That is really a surprise
free
is C function. Its signature is 20-30 years old, from times where there were no const
in C language (and there was no C++ language as well). C++ compiler treats free
like every other function, and can't let it accept const
pointer without cast, because free
could possibly change object pointed. Actually, it does, as well as delete
, but C++ doesn't know that free
is used for memory management.