Current area: HOME -> C / C++ -> Design Patterns Articles
Design Patterns
A native C++ implementation of the .NET delegate pattern
In this article, we present an implementation of the delegate pattern using C++ templates. In the accompanying demonstration project, we provide a simplistic emulation of an event source object - that we call Button - firing a Click event, together with an object we call ButtonContainer that defines a click event handler and registers it with the Button event source.
Implementing 'foreach' for C++ as a Design Pattern
Unlike the newer languages, 'C' and 'C++' do not have a built-in foreach operation. Looping over the containers is one of the most common operations. A foreach simplifies writing and reading of code. Here, a simple approach is suggested to avail this facility in C++.
Why the Double Check Lock Pattern Isn`t 100% Thread Safe
The Double Checked Locking Pattern looks like a simple way to ensure that we can make Singletons thread safe. While the simplest solution is often the best, this one contains complexities underneath that dont show until you take a closer look...a much closer look. C++ as a language has no notion of threading. Unfortunately, this makes it possible for compilers to break our programs in the most unexpected ways!
Computer Graphics World Computer graphics professionals turn to Computer Graphics World to them decide which computer graphics products to purchase to make their job more cost effective! ...
subscribe now