Asapi wrote:
Compared to malloc(), why would one say that the 'new' operator is type-safe
in a book? Thanks!
"Type-safe" loosely means that if you use the wrong type, the compiler
can tell you about it. Look at the following examples:
int* ip1 = static_cast<int*>(malloc(10 * sizeof(char)));
int* ip2 = static_cast<int*>(new char[10]);
The second line will fail to compile, whereas the first one is just fine
(at least according to the compiler).
- Adam
--
Reverse domain name to reply.