How would I write/read data to a file in binary, if I also have to define how to save my data?
I'm attempting to save some simple data structures out to a file in binary.
For example, I have a vector of structs like this:
struct Vertex
{
x;
y;
z;
}
std::vector<Vertex> vertices;
I want to save this vector out to a file in binary.
I know how to output it using ifstream
and ostream
using the <<
and >>
operators, which can be overloaded to handle my data, but they can't output binary.
I also know how to use .write() to write in binary, but the issue there is that I can't find a way to overload what I need, in order to handle my data.