There is a class in which there is a vector field from unique_ptr ( Animals is also a class), as well as methods of reading and writing to the file of this class vector. Here is the code snippet:
class Hendler { private: char* input; char* output; std::vector <std::unique_ptr <ModelObject>> * Animals; std::vector <std::unique_ptr <Event>> * E; public: Hendler(char* in, char* out, std::vector <std::unique_ptr <ModelObject> > * A, std::vector <std::unique_ptr <Event> > * Ev) : input(in), output(out), Animals(A), E(Ev) {}; void inputing() { std::fstream inputFile; inputFile.open(input); coord p, v; std::vector <std::unique_ptr <ModelObject> > Animals; // some code for (int i = 1; i <= D; i++) { inputFile >> px >> py >> pz >> vx >> vy >> vz; Animals.emplace_back(new Dragonfly(p, v, DS)); } inputFile.close(); } void outputing() { //some code for (int i = 0; i < Animals->size(); ++i) { switch ((*Animals)[i]->get_type()) { case dragonfly: out << (*Animals)[i]->get_position().x << ' ' << (*Animals)[i]->get_position().y << ' ' << (*Animals)[i]->get_position().z << ' ' << (*Animals)[i]->get_vector().x << ' ' << (*Animals)[i]->get_vector().y << ' ' << (*Animals)[i]->get_vector().z << ' ' << '\n'; break; //some code }; int main(int argc, char ** argv) { std::vector <std::unique_ptr <ModelObject>> Animals; std::vector <std::unique_ptr <Event> > Events; Hendler HendlerFile(argv[1],argv[2], &Animals, &Events); HendlerFile.inputing(); //Model Mod(&Animals, &Events); //HendlerFile.set_N(Mod.modulating(HendlerFile.get_N())); HendlerFile.outputing(); return 0; } But after doing Maine, the output file is proust ... I understand that the transfer to the Handler class of the vector is not correct, but how to do it correctly - I won’t put my mind on it .. З.Ы. the vector from main should change.
get_type()and high-riseswitch. That is why classes and inheritance were invented, so that this should not be fenced off ... - Harry