Memory Management Programs
C++ new / delete, unique_ptr. Every new needs a delete, or don't use new.
11 programs · open one, then the next
Start with Basic Pointers- 01Basic PointersBeginnerBasic Pointer Program in C++.Open example →cpp#include <iostream> using namespace std; int main() {
- 02Pointer ArithmeticBeginnerPointer Arithmetic Program in C++.Open example →cpp#include <iostream> using namespace std; int main() {
- 03Pointer to PointerIntermediatePointer to Pointer (Double Pointer) Program in C++.Open example →cpp#include <iostream> using namespace std; int main() {
- 04Array of PointersIntermediateArray of Pointers Program in C++.Open example →cpp#include <iostream> using namespace std; int main() {
- 05Pointer to FunctionIntermediateA variable that holds a function's address. Callbacks and qsort live here.Open example →cpp#include <iostream> #include <vector> #include <algorithm> #include <string>
- 06Null PointerBeginnerNull Pointer Program in C++.Open example →cpp#include <iostream> using namespace std; int main() {
- 07new and delete OperatorsBeginnerDynamic Memory Allocation using new and delete in C++.Open example →cpp#include <iostream> using namespace std; int main() {
- 08Dynamic Array AllocationBeginnerDynamic Array Allocation Program in C++.Open example →cpp#include <iostream> using namespace std; int main() {
- 09Dynamic Object CreationIntermediateDynamic Object Creation using new and delete in C++.Open example →cpp#include <iostream> #include <string> using namespace std;
- 10Memory Leak PreventionIntermediateMemory Leak Prevention and Best Practices in C++.Open example →cpp#include <iostream> using namespace std; class Resource {
- 11Smart PointersIntermediateSmart Pointers (unique_ptr, shared_ptr) in C++.Open example →cpp#include <iostream> #include <memory> using namespace std;