Contents Up << >>

Does the poor performance of ref semantics mean I should pass-by-value?

Nope.

The previous FAQs were talking about member objects, not parameters. Generally, objects that are part of an inheritance hierarchy should be passed by ref or by ptr, not by value, since only then do you get the (desired) dynamic binding (pass-by-value doesn't mix with inheritance, since larger subclass objects get "sliced" when passed by value as a base class object).

Unless compelling reasons are given to the contrary, member objects should be by value and parameters should be by reference. The discussion in the previous few FAQs indicates some of the "compelling reasons" for when member objects should be by reference.

  • Linkage-to/relationship-with C