Day 5 Flashcards

1
Q

What are Pointers?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define Functions

A

Allows programmer to create a block of code that can be called whenever task is required.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define Function Definition and its 4 parts

A
  1. Return type – returns when it has finished executing
  2. Function name- unique and descriptive as possible. Can only contain letters, numbers and underscores. Cannot begin with numbers
  3. Parameters- values passed into a function are variables declared inside of the parenthesis
  4. Function body- enclosed between {}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define Function call

A

Line of code a programmer uses to execute a function. Passing data to the function occurs through an action known as pass-by-value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define Function Prototype

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the 3 Variable Scopes?

A

Defines which part of the program can access the variable and implies how long the variable exists in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a local variable scope?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a global variable scope?

A

declared outside of any function, includinhttps://www.brainscape.com/decks/10460319/cards/quick_new_cardg main(). Exist in data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a static variable scope?

A

special blend of global and local scoping rules allow values to persist across multiple calls to the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the bypassing local scoping rules?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why are pointers useful?

A

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,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly