A
Asapi
Compared to malloc(), why would one say that the 'new' operator is type-safe
in a book? Thanks!
in a book? Thanks!
Asapi said:Compared to malloc(), why would one say that the 'new' operator is type-safe
in a book? Thanks!
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 compilerAsapi said:Compared to malloc(), why would one say that the 'new' operator is type-safe
in a book? Thanks!
malloc returns void*, new returns a pointer of the type of the object
created. e.g.
int* ip = malloc(sizeof(short));
//whoops! no compile time error, but runtime one
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.