Preexisting Classes
Our previous implementation of a reference-counted BigInt class involved some modifications to the original BigInt implementation. That required, of course, that we had the liberty to modify the BigInt source code. This option is not always available. The target class could come from a library whose source code is not given. We can still implement reference counting for such preexisting, hands-off target classes, but we need to make some design changes.
Previously, with access to the source code, we added the reference counter to BigInt by making BigInt inherit from RCObject. Now that we cannot touch the BigInt implementation, we must introduce a separate class to hold the reference count and manipulate it. Meyers calls this ...
Get Efficient C++ Performance Programming Techniques now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.