In this chapter we studied the form of C++ programs, how a program executes, and how functions can make programs easier to modify and use. We studied programs that displayed songs having repetitive verses so that an efficient use of functions would reduce
8The type string used in this chapter is not built into C++ but is supplied as a standard type. In C++, however, it’s possible to use programmer-defined types just like built-in types.
our programming efforts. At the same time, the verses had sufficient variation to make the use of parameters necessary in order to develop clean and elegant programs—programs that appeal to your emerging sense of programming style.
C++ programs have a specific form:
#include statements to access libraries comments about the program programmer-defined functions one function named main
Libraries that are part of this book and nonsystem libraries are enclosed in double quotation marks, as in "tstring.h".
Functions group related statements together so that the statements can be executed together, by calling the function.
Parameters facilitate passing information between functions. The value passed is an argument. The “box” that stores the value in the function is a parameter.
Iterative enhancement is a design process by which a program is developed in stages. Each stage is both an enhancement and a refinement of a working program.
In designing programs, look for patterns of repeated code that can be combined into a parameterized function to avoid code duplication, as we did in Verse of Program 2.8.
Prototypes are function signatures that convey to the compiler information that is used to determine if a function call is correctly formed.
Identifiers are names of functions, variables, and parameters. Identifiers should indicate the purpose of what they name. Your programs will be more readable if you are consistent in capitalization and underscores in identifiers.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here