Source: http://math.univ-lyon1.fr/~omarguin/programmation/C++Polycop1.pdf