jeudi 23 juillet 2015

A valid solution to write objects containing strings into files?

Please can someone explain the meaning of the 2nd line of the following code?

Book *B;
        B=(Book *)new char[sizeof(Book)];
        f1.read((char*)B,sizeof(Book));

This was one of the suggestions I found for writing an object of class Book (which contains std::strings ) into a file. PS-It works !!

Aucun commentaire:

Enregistrer un commentaire