C++ Concept Map

Function scope

Braces also define the scope of a function's body. Variable names declared locally can be contained anywhere between the braces. One minor break in the rules is that any parameters declared in the function header are also considered to be inside the function's scope (whereas the function name itsef is not). e.g. in

int Function(int a, int b) {
int c = a + b;
}

all the names a, b and c are considered local to the function. The name Function is non-local.


Please mail any corrections and/or suggestions to Roger Hartley at
rth@cs.nmsu.edu

Copyright © 2003 Roger Hartley