Day 5 Flashcards
What are Pointers?
- Handle large amounts of data. Special variables created in the stack whose value is in the memory address, typically in the heap or another function.
- Allows direct access to hardware or prevents duplicates of data in memory.
- Pointer is always in the STACK!!!!! , but points to heap?
- dereference- accesses data by the value of pointer variable, & address of – returns address in memory where variable is stored. allows access to members of an object pointer.
Define Functions
Allows programmer to create a block of code that can be called whenever task is required.
Define Function Definition and its 4 parts
- Return type – returns when it has finished executing
- Function name- unique and descriptive as possible. Can only contain letters, numbers and underscores. Cannot begin with numbers
- Parameters- values passed into a function are variables declared inside of the parenthesis
- Function body- enclosed between {}
Define Function call
Line of code a programmer uses to execute a function. Passing data to the function occurs through an action known as pass-by-value.
Define Function Prototype
- Looks just like the first line of the function definition, followed by a semi-colon.
- Contains one or more header files, source file containing main(), and one or more additional source files containing function definitions.
What are the 3 Variable Scopes?
Defines which part of the program can access the variable and implies how long the variable exists in memory.
What is a local variable scope?
memory, local variables are stored on program stack, and only exist while the function is running. Exist in stack (can only be modified by the block of code that created them)
What is a global variable scope?
declared outside of any function, includinhttps://www.brainscape.com/decks/10460319/cards/quick_new_cardg main(). Exist in data.
What is a static variable scope?
special blend of global and local scoping rules allow values to persist across multiple calls to the function.
What are the bypassing local scoping rules?
Pass by value- only the value of a variable is passed to the function
Pass by Reference- the address (pointer) of a variable is passed into a function allowing the function to modify a variable that exists in another function
Why are pointers useful?
they help deal with large amounts of data.
saves time instead of copying all of the data into the function, modifying it, then returning it,