Course offer · HLD · LLD · System Design at ₹799 until 30 Nov (not interview packs)

ProgramsC++

Memory Management Programs

C++ memory programs: pointers, pointer arithmetic, double pointers, function pointers, nullptr, new and delete, dynamic arrays and objects, leak prevention, and smart pointers.

11 programs · open one, then the next

Start with Basic Pointers
  1. 01Basic PointersBeginnerLearn C++ pointers from scratch: store an address with &, read and change a value through a pointer with *, and see why ptr and &ptr print different addresses.Open example →
  2. 02Pointer ArithmeticBeginnerMove through an array with pointer arithmetic in C++: ptr + i, ptr++, and ptr--. Learn why addresses jump by sizeof(int) and which positions are legal.Open example →
  3. 03Pointer to PointerIntermediateUnderstand double pointers in C++: an int** that stores the address of an int*. Follow *ptrToPtr and **ptrToPtr step by step and see where they are used.Open example →
  4. 04Array of PointersIntermediateStore addresses in an array of pointers in C++, change variables through them, and keep C-strings in const char* names[]. Also: int* p[5] vs int (*p)[5].Open example →
  5. 05Pointer to FunctionIntermediateStore and call functions through pointers in C++: arrays of function pointers, typedef, callbacks, returning a function pointer, and passing one to std::sort.Open example →
  6. 06Null PointerBeginnerUse nullptr in C++ to mark a pointer that points nowhere, check it before dereferencing, and reset it after delete. Covers NULL vs nullptr and bad_alloc.Open example →
  7. 07new and delete OperatorsBeginnerAllocate heap memory in C++ with new and new[], then free it with matching delete and delete[]. Covers uninitialized arrays, leaks, and safer options.Open example →
  8. 08Dynamic Array AllocationBeginnerCreate an array sized at run time with new int[size] in C++, then find its sum, average, max, and min. Covers delete[], size 0, and why vector is safer.Open example →
  9. 09Dynamic Object CreationIntermediateCreate objects on the heap with new in C++, use them through pointers with ->, and delete them so the destructor frees the marks array each one owns.Open example →
  10. 10Memory Leak PreventionIntermediatePrevent memory leaks in C++ with a Resource class that frees memory in its destructor and follows the Rule of Three with a deep copy and safe assignment.Open example →
  11. 11Smart PointersIntermediateManage memory automatically in C++ with unique_ptr and shared_ptr. See ownership move, reference counting with use_count, and when each object dies.Open example →