1/59
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
(*) pointer
variable that stores a memory address
Memory address
Numeric location where data is stored
(*) dereferencing
Accessing the value stored at pointer's address
(&) Address-of operator
gets memory address of variable
Stack memory
Memory automatically managed, used for local/function calls
Heap memory
Memory dynamically allocated(manually) at runtime with new, freed with delete
Static memory
memory that persists for the lifetime of the program (Global/static variables)
dynamic memory allocation
allocation memory at runtime using new
new operator
requests memory from heap and returns pointer to it
delete operator
frees memory previously allocated with new
time-space tradoff
Balancing program speed/memory use
memory leak
when allocated memory is never released, wasting space
dangling pointer
pointer that references deallocated/invalid memory
Null pointer
pointer set to 0/nullPtr that points to nothing
this pointer
implicit pointer to the object that called a member function
shallow copy
copies pointer values (addresses) but not actual data they point
deep copy
creates new memory and copies actual data, not just addresses
copy constructor
special constructor used to initialize an object from another object
destructor (~ClassName())
Function called automatically when an object goes put of scope to free resources
stream
sequence of bytes flowing between a program anbd data source/destination
input stream
reads data from keyboard/file into program
output stream
sends data from a program to screen or file
Filestream
ifstream, ofstream, fstream (enables reading/writing files)
stream manipulators
functions like setw/setfill/setprecision that format output
string stream
treats a string as input/output like a fill stream
is_open()/fail()
functions used to check if a file stream opened/closed
constructor
special function used to intialize objects when they an created
destructor
cleans up resources when object is destroyed(called when object = out of scope)
Default arguments
function parameters that have preset values if none are provided
member function
function that operates objects of a class
friend function
non-member function function that has access to private data of a class
Assignment operator (operator=)
copies one existing object to another after both are created
Rule of 3
1) Destructor
2) Copy constructor
3) assignment operator
Array
fixed size, contiguous block of elements
vector
dynamic array that resizes automatically as elements are added
string
sequence of characters managed as C++ object
Linked list
data structured made of nodes connected by pointers
node data
stored information data
node pointer (next)
points to the next node in list
null pointer
marks end of linked list (doesnt have next)
inheritance
mechanism where one class derives from properties from another
Base class/parent class/superclass
class being inherited from
derived class/child class/subclass
class that inherits from base class
"Is-a" relationship
Indicates inheritance (Dog Is-a animal)
Protected access specifier
allows access within class and its derived class
function overriding
redefining a base class function in a derived class
virtual function
base class function marked with virtual to allow overriding
runtime polymorphism/dynamic binding
deciding which function calls @ runtime
Compile-time polymorphism
function behavior determined at compile time by using parameter types
abstract base class
class that cannot be instantiated and usually has at least one pure virtual function
pure virtual function
declared but not defined in base class, must be implemented in derived class
polymorphism
ability to treat derived class objects as base class objects and call the correct overridden functions
"virtual"
enables polymorphism by marking functions as overridable
constructor order
base class run first, then derived class
destructor order
derived class run first, then base class!!
stack vs heap
stack for automatic processes, heap for dynamic processes(new/delete)
Pointers+inheritance
Needed for polymorphism
abstract base class instantiation
cannot create objects directly from it