4 ms·
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 i
by nt 16y 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.
- michaeldwp 16y agoYou 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.
- jmah 16y agoYes, 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.)