I learned C++ in the mid-90s and haven't changed my style since. What am I doing wrong?
My strategy for writing in C++ is to write in C until I suddenly think "Hey, I should totally use an object here!"
My strategy for writing in C++ is to write in C until I suddenly think "Hey, I should totally use an object here!"
http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/enable_s...
My C++ code is typically 3X shorter than corresponding C with fewer bugs and faster performance. The main issue is avoiding memory corruptions and getting away from pointers and memory leaks by leveraging the STL heavily.
I do use objects and make sure the members are C++ types rather than some C-style pointers, so that the copy and equality semantics are well defined. The key thing for me is avoiding pointers at all costs as pointers complicate memory management immensely. Use STL vector, set etc and in the worst case smart_ptr.