Home Segments Index Top Previous Next

167: Mainline

Class definitions can grow large, making it difficult and error prone to define many large member functions within a class definition. Accordingly, C++ allows you to provide just a preview of a member definition within the class definition itself, in the form of a function prototype. Then, you can define the function itself outside of the class definition.

A function prototype, definition of is like a function definition without a body. By supplying a function prototype for a member function, you supply only what the C++ compiler needs to know about a function's argument types and return type in order to compile calls to the function. The following, for example, is the function prototype for a volume member function:

double volume ( );