Example of Nested Code
void Function1(){ //begin function body
//code for Function1 indented one level
double time; //time on stack
statement one;
statement two;
if (condition) {//begin if body
//code for if statement indented two levels
bool test; //test on stack
then execute this code;
while (condition){ //begin while body
//code for while statement indented three levels
int x; //x on stack
Function2();
and so forth;
}//innermost closes first, end while body, x out of scope
another statement; //part of if statement body
onemore statement;
}//second innermost, end if body, test out of scope
//more Function1 statements would go here
}//outermost last, Function1 body, time out of scope
Last edited by:
Jenny Williams
Last modification: 11 Mar 2001
Last significant update: ?1999
|