std::string is not a POD type. A pointer is. You cannot just write a pointer to a file though. A simple way to serialize a string would be to write an uint32_t to the file first which contains the length of the string followed by length chars as returned by myString.data().
If the type of objects you try to write to the file is not known at compile time then you first need to write something to the file identifying the type, be it an enum or an actual class name (the reader must then be able to create an instance of the appropriate class and deserialize it).
The whole issue of serialization is an extremely complex issue. There is no "this fits all" solution either. It can be quiet simple and become arbitrarily complex depending on what exactly needs to be serialized.
There is of course Boost Serialization but I doubt you have knowledge of sufficient to work with it.