Can I write (bin) a vector of custom type using only one line of code ?

I have a vector that store a complex structure of data.
In example :
My_vector<My_class1>
My_class1 is a vector of My_class2
Myclass2 : some ints, doubles, etc and a vector of My_class3
Myclass3 : some ints, doubles, etc


This :
write(reinterpret_cast<char*>(My_vector), sizeof(My_vector));
does not run (my program crash...)

Maybe I can not access to the 'block' of memory information of My_vector ?
I dont know If I can do this ...
Any help ?


No.

A vector itself does not hold the information. It only holds a pointer to a dynamically allocated array. Thus the nested vectors you have are not in contiguous memory.
Topic archived. No new replies allowed.