3 ms·
I switched from C++ to Java too. Still, every time I type `new MyObject()` without a corresponding `delete` I feel like I got away with some sort of crime ;)
by ape4 4y ago
I switched from C++ to Java too. Still, every time I type `new MyObject()` without a corresponding `delete` I feel like I got away with some sort of crime ;)
- zabzonk 4y agoin c++ you probably never want to write 'new MyObject()' at all. perhaps you didn't learn c++ from a good book?
- zabzonk 4y agoto whoever downvoted this, why would you write 'new MyObject()'?
- andsoitis 4y agoI didn’t downvote and I don’t know C++, but I thought that the new and delete operators are how you manage dynamic memory allocation. Is it not the way?
- zabzonk 4y agono, it really isn't. mostly you don't need to manage objects dynamically at all (make them automatic) but if you do, use something like std::make_unique(...)
- einherjae 4y agoDepends more on when you learned C++. C++11 didn’t immediately replace C++98…