Hello, there is an array of static vector<MobilePhone*> devices; . How can you write everything inside a binary file so that when you restart the program you can read it? Thank !

  • What is MobilePhone? - Unick
  • Do you need a "binary file"? I would save to some json / yaml or xml at the worst. - KoVadim
  • @Unick, MobilePhone This is my class, the pointers to the objects of which are in the vector - Accami
  • one
    In the binary form, saving may or may not be safe or time consuming. Because if you have more than POD types in a class, then you have to handle pointers, etc. separately. That after loading all data was valid. - Unick

1 answer 1

There is no simple way. It is necessary to realize the recording of the class to the file, a separate field after the field, and accordingly - read. And call this (write) in a loop over a vector.