1/31
Flashcards covering procedural vs. object-oriented concepts, core C++ features, pointers, references, and dynamic memory basics.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Procedural Concept
The main program coordinates calls to procedures and passes data as parameters.
Object-Oriented Concept
Objects in a program interact by sending messages to each other.
Data Abstraction
Hiding implementation details and exposing only essential features.
Encapsulation
Bundling data with methods to control access; a core OO principle.
Inheritance
Mechanism to create new classes from existing ones, reusing code.
Polymorphism
Ability of different types to respond to the same interface in different ways.
Generic Programming
Writing code that works with any data type using templates and generic containers/algorithms.
Container
A data structure that stores a collection of objects (e.g., Stack, Vector, List).
Stack
A LIFO container where elements are added and removed from the top.
sort (Generic Algorithm)
A generic algorithm that orders elements in a container.
copy (Generic Algorithm)
A generic algorithm that copies elements from one container to another.
search (Generic Algorithm)
A generic algorithm to locate an element within a container.
Pointer
A variable whose value is the memory address of another location.
Dynamic Memory Allocation
Memory allocated at runtime using new/delete; managed by the programmer.
new
Operator that allocates memory on the heap and returns a pointer to the allocated object.
delete
Operator that frees memory previously allocated with new.
delete[]
Operator used to deallocate memory for arrays allocated with new[].
NULL Pointer
A special pointer value NULL; dereferencing it is an error; check before use.
Address-of Operator
The & operator that yields the memory address of a variable.
Dereference Operator
The * operator that yields the value stored at the address the pointer points to.
Pointer Variable
A variable that stores the memory address of another variable (e.g., int* ptr).
Reference Variable
An alias for another variable; must be initialized; no explicit dereferencing.
Why Reference Variables
Used to pass data to functions without copying or needing explicit address passing.
Constant Pointer
A pointer whose own value (the address it holds) cannot be changed.
Pointer to a Constant
A pointer that points to data that cannot be modified through the pointer.
Constant Pointer to a Constant
A pointer that cannot be reassigned and points to const data.
Base address of an array
The array name is its base address; it points to the first element.
Kinds of Program Data
STATIC data (compile-time), DYNAMIC data (via new/delete at runtime), AUTOMATIC data (stack)
Static Data
Memory for global and static variables allocated at compile time.
Dynamic Data
Memory allocated and deallocated at run time using new and delete.
Automatic Data
Variables created on function entry and destroyed on return (stack).
Pointers and Constants (const correctness)
Forms include pointer to const (data can't change), const pointer (pointer can't move), and const pointer to const (both).