Reimplementation of C printf for class