Functions Flashcards

1
Q

Function

A

Named list of statements invoked by a function call

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

Function Definition

A

New function’s name and a block of statements surrounded by braces
Usually appears before main() in the program file

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

Return

A

Causes execution to jump back to original calling location

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

Parameter

A

Input to function that can influence behavior

Cannot be a declaration

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

Argument

A

Value passed to a parameter

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

Return Statement

A

For function to return a value
Only one item can be returned
Multiple return statements can exist in a function

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

Void Return Type

A

Function does not return any value

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

Hierarchical Function Calls

A

aka Nested Function Calls

Functions included in a function call

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

Reasons for functions

A
  1. Improve program readability
  2. Modular program development
  3. Avoid writing redundant code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Function Stub

A

Function definitions whose statements haven’t been written yet.

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

Stack Frame

A

Each function call creates a new set of local variables.

Return causes local variables to be discarded.

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

Pass By Value

A

Assigning a normal parameter does not update argument’s variable

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

Pass By Reference

A

Updates the argument variable

Append “&” to a parameter’s data type

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

Local Variable

A

Variable whose scope is limited to the function it was declared in.

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

Global Variable

A

Variable whose scope is the from declaration to the file’s end and reaches into functions.
Use in functions should be limited.

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

Function Declaration

A

aka Function Prototype

Gives compiler enough information to recognize a valid function call. Function definition appears later in the file.

17
Q

Default parameter value

A

During function definition, the last parameter(s) are optional and have a default value included in the definition

18
Q

Function Name Overloading

A

Two functions with the same name but different number of types of parameters

19
Q

Virtual Function

A

Member function that may be overridden in a derived class when runtime polymorphism is used