CISC 1600 Lecture Notes - Lecture 19: Function Prototype, Global Variable, Local Variable

149 views5 pages

Document Summary

Defined within a function or block and is redefined each time function is called. Scope = from the variable def to the end of the function, accessible only within the function or block. Other functions can define variables with the same name. When a function is called, local variables in the calling function are not accessible from within the called function. Lose their contents when function terminates (in contrast to static that keeps them) Outside the bound of all the functions. Scope (domain)= from the variable definition to the end of the entire program, accessed by all function. Not easy to use for other programs (lots of modification) Constant is fine initialized to 0 (numeric) or null (character) Not available / override by local variable if the local variable shares the same name. //this program shows that variables defined in a function are hidden from other functions. #include using namespace std; void anotherfunction(); // function prototype int main()

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents