Library

Course: C/C++ Pointers & Applications

C/C++ Pointers & Applications

  • Life Time Access
  • Certificate on Completion
  • Access on Android and iOS App
  • Self-Paced
About this Course

C & C++ are very powerful languages when it comes to performance & flexibility. But there are some features that are complex and take time to master. One of such features is pointers. Pointers is what separates C/C++ from other languages. These are incredibly powerful as they allow programs to access memory directly and manipulate it.

This course focuses on pointers and their applications.It leans more towards implementation in C++, rather C. You'll learn the basics of pointers and then move on to understanding and implementing arrays, pointers to arrays & heap based arrays. You'll also learn advanced memory management by creating a custom dynamic array (just like std::vector<T> in standard C++ library). You'll use placement new & delete to directly place objects in a memory pool allocated through operator new function. As you'll see later in the course, this is a powerful mechanism to optimize usage of heap memory with user-defined objects.

After arrays, you'll learn how to use pointers to create node-based data structures. We'll focus on two types of linked lists - singly & doubly linked lists. You'll understand the difference between arrays and lists and also learn how to access the elements of both the data structures without having to know their internal structure. This is possible by creating context variables that allows access in a container-agnostic manner. 

Pointers are invaluable while working with strings. You'll learn how to create dynamic strings using pointers. This will be shown with an implementation of a string class.

The next important topic you'll learn and implement will be function pointers. You'll understand how function pointers work and how we can simplify their syntax. You'll also master the complexity of creating arrays of function pointers and functions that return function pointers. On top of that, you'll be comfortable with functions returning pointer to functions that themselves return pointer to other functions. Confused? See the section on function pointers.

That's not all. You'll also learn how to create pointer to members (which have even a more complex syntax than function pointers). 

Furthermore, you'll learn how to create callbacks through functions pointers. This course will show you how to optimize the callbacks through function objects. Function objects are more powerful than functions pointers as callbacks.We'll use this knowledge and apply it in many examples to reinforce the concept of pointers to functions.

This course also introduces some commonly used containers of the C++ standard template library (STL), such as std::array, std::vector & std::list. By the time you hit these topics, you'll already know how these are implemented internally. How about that!

This course relies on some modern C++ (C++11) features to simplify things, such as auto, std::initializer_lists, type aliases. Even if you don't know about these features, the course has videos on these topics to get you started. Additionally, there are four full length videos dedicated to discussion on move semantics.

I hope you enjoy this course!

Basic knowledge
  • Basic knowledge of C & C++
  • Should understand basic syntax of pointers
What you will learn
  • Understand in depth how pointers work
  • Understand the applications of pointers
  • Understand efficient implementation of basic data structures
  • Understand how callback mechanism works through pointers and objects
Curriculum
Number of Lectures: 79
Total Duration: 06:52:12
Introduction
  • Introduction - Resource Files  

    Source Code for modern C++ lecture & introduction to pointers.

  • Introduction  

    Introduction of the course.

  • Quick Intro to Modern C++ (C++11/14)  

    This lecture covers some basic features of Modern C++ (C++11/14). These features are used extensively in the subsequent lectures and make it easier to write code and make it more expressive.

  • Introduction to Pointers  

    Learn about the basics of pointers, stack, heap and data section.

  • Examples of Pointers  

    This lecture will show an example of using pointers. We'll examine them using the memory window of Visual Studio.

Static Arrays
  • Static Arrays - Resource Files  

    Source code for arrays section.

  • Static Arrays - Array Basics  

    Introduces static arrays (arrays that are created on stack, at compile time)

  • Static Arrays - Examples  

    This lecture demonstrates usage of arrays and their representation in the memory.

  • Static Arrays - Array as Function Argument  

    Demonstrates how arrays can be passed as arguments into functions.

  • Static Array - Array as Reference Argument  

    Demonstrates how arrays can be passed by reference into functions through templates.

  • Static Array - Introduction to std::array<T>  

    A gentle introduction to standard library std::array.

  • Static Array - Heap-based Arrays  

    Learn how to create dynamic arrays on heap through new operator. You'll also see how dynamic arrays are represented in the memory.

  • Static Array - Multidimensional Arrays  

    This video discussed multi-dimensional static arrays and their syntax along with pointers to such arrays. You'll also learn how to pass multi-dimensional arrays to functions.

  • Static Array - Multidimensional Arrays on Heap  

    Here, you'll learn how to create multi-dimensional arrays on heap using new and how they are represented in heap memory. 

Dynamic Array
  • Dynamic Array - Resource Files  

    Provides the code for the dynamic array and the Noisy class. This class is used for debugging in dynamic arrays.

  • Dynamic Array - Introduction  

    Revisits dynamic arrays on heap and discusses their advantages in comparison with static arrays. This lecture also explains the Dynamic Array project along with the important functions.

  • Dynamic Array - Constructors  

    In this part, we'll implement different kinds of constructors in the dynamic array class.

  • Dynamic Array - Accessors  

    Here, we'll add accessor functions (back, front, getat, etc).

  • Dynamic Array - Modifiers  

    This lecture explains implementation of important functions such as Add & Insert.

  • Dynamic Array - Element Erasure  

    Here, we'll discuss how to implement the erase functionality in the dynamic array.

  • Dynamic Array - Copy/Move Semantics - Part I  

    This is the start of four-part discussion on move semantics. Move semantics is a very important part of C++11 as it greatly improves the performance of the code. 

    This part prepares the groundwork by explaining the basics of rvalue and lvalue references and also demonstrates different function overloads based on value types.

  • Dynamic Array - Copy/Move Semantics - Part II  

    The second part discusses lvalues & rvalues with class objects.

  • Dynamic Array - Copy/Move Semantics - Part III  

    Here, we'll discuss how move and copy semantics work.

  • Dynamic Array - Copy/Move Semantics - Part IV  

    In this part, you'll learn how to implement move constructor and assignment in the Integer class. You'll also understand when move semantics are used by the compiler for objects of the class.

  • Dynamic Array - Copy/Move Semantics Implementation  

    In this lecture, we'll implement move and copy semantics in the dynamic array class and understand how this improves the performance of our code.

  • Dynamic Array - Issues  

    The dynamic array class has several issues due to usage of new[] operator. This video explains all these issues in depth.

  • Dynamic Array - Placement new & delete  

    Placement new is a very powerful operator for creating an object without allocating memory. Using this operator, this lecture demonstrates how it can help us overcome the issues in the dynamic array class.

  • Dynamic Array - Smart Reallocation  

    This lecture builds explains and demonstrates how the placement new operator can be used to dynamically & efficiently grow a heap-based array.

  • Dynamic Array - New Dynamic Array I - Constructors  

    We'll create a new dynamic array in this video and implement smart reallocation technique in it. We'll start by implementing constructors and a destructor.

  • Dynamic Array - New Dynamic Array II - Add Function  

    Here, we'll implement the Add function in the new dynamic array class.

  • Dynamic Array - New Dynamic Array III - Insert Function  

    Discusses implementation of the Insert function.

  • Dynamic Array - New Dynamic Array IV - Miscellaneous Functions  

    We'll add some more functions in the array class and also fix some bugs.

  • Dynamic Array - Conclusion  

    This lecture revisits the pros and cons of arrays - both static and dynamic. It also proposes an alternative data structure called list, which we shall discuss in the next section.

Singly Linked Lists
  • Singly Linked Lists - Resource Files  

    Source code for singly-linked list.

  • Singly Linked Lists - Introduction  

    This lecture explains the basics of linked lists. You'll learn how pointers are used to create nodes which ultimately form a chain, called linked list.

  • Singly Linked Lists - Basic Functions  

    We'll add the common functions in the list class, but implement them in subsequent videos.

  • Singly Linked Lists - Modifiers - AddFront & AddBack  

    We'll implement the Add function in this lecture.

  • Singly Linked Lists - Constructors  

    In this video, we'll implement various constructors in the list.

  • Singly Linked Lists - Copy/Move Semantics  

    In this video, we'll implement move and copy semantics in the list.

  • Singly Linked Lists - Modifiers - Insertion  

    You'll learn how to insert a new element in the list, by creating a node and inserting at the correct position in the list.

  • Singly Linked Lists - Modifiers - Erase  

    You'll learn how to remove elements by erasing nodes from the list without breaking the chain of nodes.

  • Singly Linked Lists - Issues  

    To access the elements of the list, we expose the head pointer to the users. This is a violation of encapsulation and you'll learn how to prevent this. 

  • Singly Linked Lists - Element Access  

    We'll further encapsulate the List class. We'll also add support for element access without exposing the node pointers.

Doubly Linked Lists
  • Doubly Linked Lists - Basic Functions I  

    You'll understand the basic structure of a doubly linked list. We'll start adding common functions in a list class.

  • Doubly Linked Lists - Basic Functions II  

    In this video, we'll implement a few accessor functions (Front, Back).

  • Doubly Linked Lists - Modifiers - Add  

    You'll learn how nodes are added to doubly linked list at the front and back.

  • Doubly Linked Lists - Accessors  

    In this video, we'll implement support for element access through the Position context class.

  • Doubly Linked Lists - Constructors  

    We'll complete the implementation of the constructors.

  • Doubly Linked Lists - Modifiers - Front & End Removal  

    In this video, we'll implement the functions to remove elements at the front and back of the list.

  • Doubly Linked Lists - Modifiers - Insertion  

    Here, you'll learn how new nodes can be inserted in the list by implementing the Insert function.

  • Doubly Linked List - Modifiers - Erase  

    In this video, we'll implement the erase function and learn how to remove nodes from the list at any position.

Strings
  • Strings - Resource Files  

    Source code for Strings section.

  • Strings - Basics  

    Introduces the basic concepts of strings and how they're represented as arrays.

  • Strings - String Length  

    Shows the implementation of calculating the length of the string.

  • Stings - Copy & Join  

    Shows the implementation of copying and joining/concatenating strings.

  • Stings - Copy through Allocation  

    Shows how to create a duplicate of a string through dynamic memory allocation.

  • Strings - String Class  

    We'll put together the concepts learnt in the earlier videos of string and create a string class. This class will manage the memory allocation/deallocation automatically.

Function Pointers
  • Function Pointers - Resource Files  

    Source code for function pointers.

  • Function Pointers - Basics I  

    This lecture introduces the concept of function pointers. 

  • Function Pointers - Basics II  

    Demonstrates function pointers with more examples.

  • Function Pointers - Function Pointers As Arguments  

    Here, you'l learn how to pass function pointers as arguments to functions

  • Function Pointers - Function Pointers As Return Values - I  

    This lecture explains how function pointers can be returned from functions as values.

  • Function Pointers - Function Pointers As Return Values - II  

    More examples of function pointers as return values.

  • Function Pointers - Arrays Of Function Pointers - I  

    You'll learn how to create array of function pointers.

  • Function Pointers - Arrays Of Function Pointers - II  

    Shows how to return an array of function pointers from a function. You'll also learn how to create a dynamic array of function pointers on heap.

Pointer To Member
  • Pointer to Member - Resource Files  

    Source code for Pointer to member section.

  • Pointer to Member - Basic Syntax  

    Introduces the syntax of creating pointer to a members of a class.

  • Pointer to Member - Constant Member Functions  

    Explains how to create a pointer to a constant members of a class.

  • Pointer to Member - Simplifying Through Macros  

    Here, you'll learn how to simplify the syntax of using pointer to members.

  • Pointer to Member - Static Members  

    This lecture explains how to create pointers to static members of a class.

Callbacks
  • Callbacks - Resource Files  

    Source code for Callbacks section.

  • Callbacks - Introduction  

    In this lecture, we'll discuss an example of a Find algorithm that will serve as the foundation for learning callback concept later.

  • Callbacks - Function Pointers As Callbacks  

    Here, you'll learn how function pointers can be used as callbacks.

  • Callbacks - Function Pointers Example  

    We'll see another example of function pointers as callbacks in this video.

  • Callbacks - Member Function As Callback  

    This lecture demonstrates usage of member functions as callbacks through templates.

  • Callbacks - Function Objects  

    This video explains the basics of function objects.

  • Callbacks - Function Objects As Callbacks  

    In this lecture, you'll learn and understand how function objects are used as callbacks instead of function pointers.

  • Callbacks - Function Object Internals  

    We'll go deep into the internals of how the compiler invokes a function pointer and a function objects. Consequently, you'll come to appreciate the advantages of using function objects as callbacks.

  • Callbacks - Function Objects Vs Function Pointers  

    You'll learn the key differences between function pointers and function objects as callbacks. You'll also learn how to choose between the two when you want to use a callback.

Reviews (0)