#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>

class BaseSaveFile {

protected:
    std::vector<float> first_vector;

public:
    void fill_vector(std::vector<float> fill) {
        first_vector = fill;
    }
    void show_vector() {
        for ( auto x: first_vector )
        std::cout << x << std::endl;
    }
    std::istream& load(std::istream& is){
    	size_t vsize; 
    	if(is.read((char*)&vsize, sizeof(vsize))) {
    	    first_vector.resize(vsize);
    	    is.read((char*)first_vector.data(), vsize*sizeof(float)); 
    	}
    	return is; 
    }
    std::ostream& save(std::ostream& os){
    	size_t vsize=first_vector.size(); 
    	os.write((char*)&vsize, sizeof(vsize));
    	os.write((char*)first_vector.data(), vsize*sizeof(float)); 
    	return os; 
    }

};


class DerivedSaveFile : public BaseSaveFile {


};


int main ( int argc, char **argv) {

    DerivedSaveFile derived;
    std::vector<float> fill;
    for ( auto i = 0; i < 10; i++) {
        fill.push_back(i);
    }
    derived.fill_vector(fill);
    
    std::cout<<"Original:"<<std::endl; 
    derived.show_vector();

    std::stringstream ios;
    derived.save(ios); 
    ios.seekp(0); 
   
    std::cout<<"Reloaded:"<<std::endl; 
    DerivedSaveFile d2; 
    d2.load(ios);
    d2.show_vector();
    
}