Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Reference counting is available in C++ through the use of smart pointers ( ex. boost::shared_ptr ). In fact unlike Objective C there is no need to explicitly increment/decrement the reference count.


Yes, but the problem is that it's just one approach out of many, so when using other libraries and APIs, you have no consistency. (For example, you'll have to wrap their classes in your refcounting scheme, and unwrap when passing them back in.)


You can also just make your own CSmartObject base class (which does reference counting), and just have all of your objects inherit from that.

Reference counting may not be built into C++ itself, but it's not super difficult to add in either.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: