The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details.


Functions for Objects

In the next few sections, I will demonstrate several possible interfaces for functions that operate on objects. For some operations, you will have a choice of several possible interfaces, so you should consider the pros and cons of each of these:

pure function Takes objects and/or basic types as arguments but does not modify the objects. The return value is either a basic type or a new object created inside the function.
modifier Takes objects as parameters and modifies some or all of them. Often returns void.
fill-in function One of the parameters is an "empty" object that gets filled in by the function. Technically, this is a type of modifier.


Last Update: 2005-11-21