<p>When creating a class library in C++, you can choose between dynamic (<code>.dll</code>, <code>.so</code>) and static (<code>.lib</code>, <code>.a</code>) libraries. What is the difference between them and when is it appropriate to use which?</p>

If your library is going to be shared among several executables, it often makes sense to make it dynamic to reduce the size of the executables.  Otherwise, definitely make it static.
There are several disadvantages of using a dll.  There is additional overhead for loading and unloading it.  There is also an additional dependency.  If you change the dll to make it incompatible with your executalbes, they will stop working.  On the other hand, if you change a static library, your compiled executables using the old version will not be affected.