Hacker News new | ask | show | jobs
by nt 5599 days ago
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.
2 comments

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.