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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access