10 ms·
I agree with most of what he says but not with his memory management argument. In C++ you could do something like this: f() { LinkedList list; popula
by fauigerzigerk 16y ago
I agree with most of what he says but not with his memory management argument. In C++ you could do something like this:
f() {
LinkedList list;
populate(list);
use(list);
//forget
}
Freeing the list elements is done in one place only, in the destructor of LinkedList. In C, you have to call some kind of free function in every single place a LinkedList is used. The burden of managing memory is on the user of a library, not on its creator. I don't think this is enough to justify using C++ though.
- yonilevy 16y agoThank you for bringing that up. It's called RAII and it's one of my favorite features of C++. The fun thing about it is that it can also be used to manage other resources such as files, sockets, locks or what not.