ENGR 101 Lecture Notes - Lecture 9: Function Prototype, Dwayne Johnson
Document Summary
A function is an abstraction over a chunk of computation. The interface for a function describes how we use it. The implementation contains code to make the function work. C++ does not allow returning more than one value and the return statement determines the return value. A variable can only be sued after its declared and only within a scope. Variables declared outside of the function have a global scope. To make a variable that will never change, use the fucntion const. Almost all other variables have a local or block scope. A block is a chunk of code enclosed by {}. Block scope also applies to control flow structures like if, for and while. A function prototype declares a function before it is actually defined. Different scopes can have variables with the same name . There are two mechanisms for parameter passing in c++: