Design your classes so that using them is just like using a primitive type in C. This allows the client to use them in a style which is natural for C. In cases where you want to avoid copying, pass arguments by reference. Use pointers only when you want a truly dynamic data structure, or when polymorphism demands it (note that references allow for polymorphism also, as they are really just a different kind of pointer).
If your problem naturally calls for value semantics, but you don't want to pay the overhead of copying, see "Surrogate objects" on page 121.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.
Generated with WebMaker