Blocks, Functions and Reference Variables

  • Joe Pitt-Francis
  • Jonathan WhiteleyEmail author
Part of the Undergraduate Topics in Computer Science book series (UTICS)


The code developed up to this point has been largely restricted to code that may be placed inside a single set of curly brackets. Readers with previous programming experience will be aware of the limitations this places when writing code. For example, if we were to apply the same operations in different places in the code we would have to repeat the lines of code that performed these operations everywhere in the code where they were required. This would result in a lengthy, unwieldy program where we would have to maintain identical fragments of code. It would be much more convenient if we could write a function that we could call whenever we wanted to perform these operations. This chapter introduces the C++ machinery for writing functions. We also introduce reference variables: these are an attractive feature of the C++ programming language that simplifies the writing of functions.


Reference Variables Previous Programming Experience Double Precision Floating Point Variables Function Prototype User-specified Function 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Copyright information

© Springer-Verlag London Limited 2012

Authors and Affiliations

  1. 1.Department of Computer ScienceUniversity of OxfordOxfordUK

Personalised recommendations