The usual C++ practice for passing class objects to a function is to use references. For instance, you would use reference parameters for functions taking objects of the
ifstream classes as arguments.
Let’s look at an example that uses the
string class and illustrates some different design choices, some of them bad. The general idea is to create a function that adds a given string to each end of another string. Listing 8.7 provides three functions that are intended to do this. However, one of the designs is so flawed that it may cause the program to crash or even not compile.
// strquote.cpp -- different designs#include <iostream>#include <string> ...