Design Patterns - Singleton Pattern | Explanation and Implementation in C++

►Software Design and Design Patterns Playlist:    • C++ Software Design and Design Patterns   ►Find full courses on: https://courses.mshah.io/ ►Join as Member to Support the channel:    / @mikeshah   ►Git Repo: https://github.com/MikeShah/DesignPat... ►Lesson Description: In this lesson I show you how to implement a creational design pattern in C++ known as the singleton. This is a controversial pattern to many in that it can be misused, however, the pattern itself can be useful when we truly need only 1 point of access for a specific class (e.g., a file system or logger). This lesson will also refresh you on the idea of 'static' which is a clean way to implement the singleton pattern. Useful resource on understanding static https://en.cppreference.com/w/cpp/lan... 00:00 Design Patterns are not perfect 00:58 Creational Design Pattern 2:25 Sample Logger Class 4:10 Creating multiple instances of an object 5:15 Utilizing access modifiers of class for constructor 6:06 Idea of a GetInstance member function 7:06 The static keyword 7:50 static function example 10:22 Practical use case of static in a class 11:00 Initializing static member variables 13:30 A static pointer to instance of our class as member variable 15:40 Utilizing a member function from our single instance 16:50 Creating a static member function 17:37 Implementing our logger class 19:10 Allocating memory for our pointer 20:50 Adding messages to our logger 22:18 Careful with returning pointers to member variables 24:20 Design to protect your clients of your API 25:10 Create the static variable within GetInstance 27:30 Other design considerations and closing ►YouTube Channel:    / mikeshah   ►Please like and subscribe to help the channel! ►Join our free community: https://courses.mshah.io/communities/...