Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
pimpl example 1: Lizard implementation in one file using boost::shared_ptr is a pimpl example.
Most lizards remain having the same gender for all their live. Therefore, it is a good idea to make a lizard's gender a const member variable. Problem is, that this makes a lizard class uncopyable. In this example I solve this by making a Lizard contain an opaque pointer to LizardImpl, where a LizardImpl does have a constant gender. Because I want to be able to do a shallow copy on Lizards, I use a boost::shared_ptr. Also note that the code is very similar to a Strategy design pattern.
Operating system(s) or programming environment(s)
Libraries used:
TEMPLATE = app |
#include <cassert> |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.
This page has been created by the tool CodeToHtml