'How to save a vector of a custom type of elements on disk, read it, and parse it into a vector again using C++

The vector type is TrackInfo:

class TrackInfo
{
public:
    TrackInfo(URL& _url, String& _title, double& _length, String _fileFormat);

    URL url;
    String title;
    double length;
    String fileFormat;
};


====================================================================================

std::vector<TrackInfo> tracks;
TrackInfo track(fileURL, fileName, length, fileFormat);
tracks.push_back(track);
tracks.push_back(track);

So, how can I save this vector on the computer and then reread it when I need and convert the file into the same vector again?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source