Sample code for Genetic Algorithms

Here is some sample C++ (pseudo)code for how to implement a basic Genetic Algorithm:

The basic Genetic Algorithm classes

Sample implementation - Optimise a function over some interval

Be warned though, that this GA code is a bit of a hack, and is not very object-oriented. In particular, the separation of the abstract GA classes from the user application is not very good. I'm sure you can figure out a more elegant design yourself.