Tutorial by Examples

The Monostate pattern is usually referred to as syntactic sugar over the Singleton pattern or as a conceptual Singleton. It avoids all the complications of having a single instance of a class, but all the instances use the same data. This is accomplished mostly by using static data members. One o...
In contrasto to the Singleton, the Monostate is suitable to be inherited to extend its functionalities, as long as member methods are not static. It follows a minimal example in C++: struct Settings { virtual std::size_t width() const noexcept { return width_; } virtual std::size_t heigh...

Page 1 of 1