1/58
C++
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Procedure or Subroutine
A function is a name section of a program that performs a specific task, so a function is this
Void function
A function that does not return a value
Code block
Enclosed group of statements inside a set of braces
Function Definition
Contains the interface to the function as well as the statements that make up the function
A function call
A statement that causes a function to execute
A parameter
A special variable that holds a value being passed into a function
Function prototype
Eliminates the need to place a function definition before all calls to the function
Body of the function
The set of statements that perform the function’s operation
Modular Program
Several small functions to solve a specific parts of a problem
Static local variables
Exist for the life time of the program outside scope of function.
Function
A collection of statements that performs a specific task
Arguments
Values that are sent to a function
Function Overloading
A concept to define two or more functions with the same name with unique signatures.
Function Header
The very first line of a function definition
Default Arguments
Passed to parameters automatically if no argument is provided in function call
Global Variable
Defined outside all functions and is accessible to all functions
Flow of execution
The order in which statements are executed in a program
A library
A package of code that is meant to be reused by many programs
Passed by value
When a copy of an argument is passed to a function.
Driver code
A code that tests a function by simply calling it
A function, procedure, or subroutine
A programming construct that allows a programmer to associate a given set of instructions with a specific name
Incremental Development
Involves writing and testing small portions of a programs repeatedly until the program is complete.
Local Variable
Defined inside a function and is not accessible outside the function.
A stub
A dummy function that is called instead of the actual function it represents.
Library
A collection of precompiled routines that a program can use
Formal parameters
The list of parameters indicated in the functions definition
Dead or unreachable code
Is a part of the source code of a program which can never be executed because there exists no control flow path to the code
Return value
A function sends a value to the part of the program that executed it
Static variables
Variables that are defined inside a function that remain in memory after the function has finished executing.
Passed by Reference
When a reference variable is used as a parameter.
reference variables
Allow a function to access the parameter’s original argument
True
A problem can be solved with recursion of it can be broken down into successive smaller problems that are identical to the overall problem.
True
Any problem that can be solved recursively can also be solved iteratively, with a loop. In fact, recursive algorithms are usually less efficient than iterative algorithms. This is because a function call requires several actions to be performed by the C++ runtime system. These actions include allocating memory for parameters and local variables and storing the address of the program location where control returns after the function terminates. These actions, which are sometimes referred to as overhead, take place with each function call. Such overhead is not necessary with a loop
Recursive
A function is one that calls on itself
indirect recursion
occurs when function A calls function B, which in turn calls function A.
Base Case
The part of a calculation that can be solved without recursion. This stops the recursive function from continuing to call itself.
Direct recursion
When a recursive function calls itself
Subscript (index)
The number inside an array’s brackets in an assignment statement, or any other statement that works with contents of the array. Can also pinpoint a specific location in a array.
Size declarator
The number inside the brackets of an array definition
Iterator
An STL object that behaves like a pointer and is used to access the individual data elements in a container
Bounds Checking
C++ does not perform this, and means you can write programs with subscripts that go beyond the boundaries of a particular array.
Subscript operator
Data in a standard C++ array is accessible only via this
Array
Allows you to store and work with multiple values of the same data type.
Subscript operators (push_back())
Data can be stores in a vector via this member function.
Range-based for loop
Receives the value of a different container element during each iteration of this. During the first loop iteration, it receives the value of the first element; during the second iteration, it receives the value of the second element and so forth.
pop_back()
Removes the last element from a vector
Range Variable
Receives the value of a different container element during each iteration
Vector
Holds a sequence of values stored in contiguous memory locations
Algorithms
Provided by the STL are implemented as function templates
element
each storage location of an array
resize()
Member function increases the number of values that a vector may store by the number indicated by its first argument.
clear()
Completely delete the contents of a vector.
at()
Retrieve the value of an element in a vector
size()
Vectors can report the number of elements they contain
empty()
Returns true if no data is stored in the vector
containers
The data types that are defined in the STL are commonly called this.
Off-by-one error
Starts at 1 instead of 0
capacity()
To determine the number of values that may currently stored in a vector
Standard template library
A collection of data types and algorithms that you can use in your programs (programmer defined and not part of C++)