3 ms·
how exactly do you think C and C++ differ here?
by zabzonk 10mo ago
how exactly do you think C and C++ differ here?
- lelanthran 10mo ago> how exactly do you think C and C++ differ here? `new` throws, `malloc` returns. That's a pretty big difference! Idiomatic C++ code never puts a `try` around `new`, while idiomatic C code always checks the return from an allocation.
- zabzonk 10mo agoWell: https://en.cppreference.com/w/cpp/memory/new/nothrow.html https://en.cppreference.com/w/cpp/memory/new/nothrow.html I thought you were talking about the use of malloc in both languages - you never mentioned new in your first post. and i think we have different views on what is "idiomatic" in the languages.
- lelanthran 10mo ago> I thought you were talking about the use of malloc in both languages - you never mentioned new in your first post. and i think we have different views on what is "idiomatic" in the languages. That's fair, but malloc is certainly non-idiomatic, isn't it?