1/19
Flashcards covering pointers, dynamic memory allocation, class design for dynamic arrays, and the Bag/String/Polynomial ADTs.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Dereference operator (*p)
A syntax that refers to 'the box p points at' (the value stored at the address contained in the pointer p).
Address-of operator (&)
An operator used to retrieve the memory address of a specific variable.
Heap
The location where dynamic variables reside, described as a 'rental warehouse' that must be manually returned using delete.
Run-time stack
The memory location where local variables reside, which automatically clean themselves up.
Default constructor
The no-argument constructor used by C++ to initialize every element when allocating an array of objects.
Reference parameter for pointers
A parameter used when a function reassigns a pointer itself and needs that redirection to survive outside the function.
Array name as argument
The practice of passing an array by its name alone, which acts as a pointer to the first element.
Bag constructor (Dynamic Memory Timing)
The point in the Bag ADT lifecycle where the dynamic array is allocated via new.
Friend function
A non-member function uniquely declared to have access to the private data members of a class.
Self-application
A situation where the argument of a function is the same object running the function, occurring in statements like a = a or a += a.
Resizing Performance
Growing with n elements, usually resulting in linear time (O(n)) worst-case performance for container resizing.
Law of the Big Three
The rule that a class using dynamic memory should provide three member functions: the destructor, the copy constructor, and the assignment operator.
Copy constructor usage
Triggered when calling a function with a value parameter, declaring a variable as a copy of a existing object, or returning a value from a function.
C-string storage requirement
A char array must contain exactly enough slots for the letters plus one hidden terminator character (\text{'\0'}) marking the end.
Function Overloading signature
The unique parameter lists that allow the compiler to distinguish between multiple operators or functions with the same name.
std::bad_alloc
The exception thrown by new when the heap is out of memory.
Shallow Copy
The automatic compiler-generated assignment that copies the data pointer rather than the underlying array, causing two objects to share the same storage.
Deep Copy
An assignment operator implementation that provides a new object with its own separate array, avoiding the problems of shared storage and dangling pointers.
Amortized Constant Time (O(1))
The average cost per insertion achieved when resizing a container by a multiplicative factor (e.g., doubling capacity) rather than adding a single slot.
Polynomial Degree
The highest exponent in a polynomial that has a non-zero coefficient.