Skip to main content Accessibility help
×
Hostname: page-component-7479d7b7d-68ccn Total loading time: 0 Render date: 2024-07-12T05:52:46.219Z Has data issue: false hasContentIssue false

5 - Functions and Function Calls

Published online by Cambridge University Press:  13 January 2010

Frantisek Franek
Affiliation:
McMaster University, Ontario
Get access

Summary

System stack, activation frame, activation frame as the storage for local auto objects and for function arguments. Passing arguments by value as opposed to by reference. Calling sequence. Recursion and its relation to activation frames and the system stack. The price of recursion.

Any program of even modest complexity must be modularized for many reasons: readability, testability, validation, extendibility, maintainability, and many others, all outside the scope of this book. However, we assume that the reader understands that any reasonable programming language must allow for some modularization; C and C++ are no exceptions. Besides modularization on the level of source files, virtually the only modularization feature of C consists of structuring a program into separate functions. The object orientation of C++ allows for a more complex and far better-controlled modularization.

A C/C++ function is a programming module with a precisely defined interface that consists of the function's header, which specifies the function's name, the data types of the arguments (the input to the function - though it is possible for a function not to have any arguments), and the data type of a single return value (the output of the function; again, it is possible for a function to return nothing at all). Let us observe that computer scientists prefer to speak of procedures (if no value is returned) and functions (if a value is returned and the execution has no “side effects”, meaning that it does not modify any data not local to the function).

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2003

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Functions and Function Calls
  • Frantisek Franek, McMaster University, Ontario
  • Book: Memory as a Programming Concept in C and C++
  • Online publication: 13 January 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511584046.006
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Functions and Function Calls
  • Frantisek Franek, McMaster University, Ontario
  • Book: Memory as a Programming Concept in C and C++
  • Online publication: 13 January 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511584046.006
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Functions and Function Calls
  • Frantisek Franek, McMaster University, Ontario
  • Book: Memory as a Programming Concept in C and C++
  • Online publication: 13 January 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511584046.006
Available formats
×