O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.3. Reference Counts

The class design boilerplate from Chapter 7 organizes and centralizes the important dynamic behaviors of objects with copy() and free(). In particular, the boilerplate makes sure that different objects do not use the same resource (free store memory, files, and so forth) and that changes to one object's state do not affect the state of another one. This approach makes class design robust and consistent with objects that you instantiate.

Classes that allocate and deallocate resources in their constructors and destructors are candidates for reference counts that manage a resource. Reference counts improve efficiency with classes that read from resources more often than they write to them. Applications that call copy(), for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required