a c++ abstract factory implementation