I think you have to pass ios::trunc flag to the fstream constructor so that the file will be created if it doesn't exist.
This will just copy the bytes of A to the file. This works for simple types but will not work when you have pointers and dynamic allocations.
std::string contains at least one pointer internally that points to the characters. Only the pointer will be written to file. The actual character data will not be written to file. When you later try to read the string from the file the internal string pointer will be set but the memory has probably been deallocated already and might be used by other objects and so things will go bad, and possibly result in a crash.
It's better to read and write each class member separately and handle non-POD types like std::string in a way that makes sense for that type.
One way to write a std::string to file is to first write the size of the string to the file, and then write the characters.