Introducing Structure into Your Programs
Ivor Horton · 2010
This chapter talks about the basics of program structure. It describes how functions are defined, how data can be passed to a function and how to pass pointers to functions. Functions are fundamental to programming in C++. The use of references as arguments is an important concept. The pass - by - reference parameter eliminates any copying of the argument supplied and allows the function to access the caller argument directly. The return expression can be any expression, as long as it ends up with a value of the required. Passing values to a function using a reference can avoid the copying implicit in the pass-by-value transfer of arguments. Parameters that are not modified in a function should be specified as const. When a C++/CLI is passed as array to a function, there is no need for another parameter for the length of the array.