how to use ofstream for a specific class