3 ms·
I didn't have any trouble with the C examples, but with C++ it just puzzles me why people would want to use a language like that in the first place. What does i
by jgreen10 13y ago
I didn't have any trouble with the C examples, but with C++ it just puzzles me why people would want to use a language like that in the first place. What does it buy you except bigger head aches?
- widdershins 13y agoIt buys you the speed of C (or close), with nice abstractions. And when you use destructors correctly, it can provide pretty much automatic memory management too, much safer than C. And it's pretty simple to avoid all these warts, just... you know don't write them. On the other hand I don't have any experience with old C++ codebases, which is where you're likely to find this hellish stuff.
- dman 13y agoRAII.
- jgreen10 13y agoYou don't need RAII if you don't have exceptions. Separating allocation and initialization is a good thing.
- dman 13y agoRAII is used for idiomatic cleanup from a function. In C the way to handle that would be to have a cleanup section in every function and then doing a goto to that which adds clutter to the function.