Hello guys and gals :)
I admit I don't know whether there is a way to create a dynamic array of objects. I have a task to read a file with the structure:

body_id x_low x_high y_low y_high z_low z_high

body_id x_low x_high y_low y_high z_low z_high

body_id x_low x_high y_low y_high z_low z_high

where <body_id> is a string and the rest are integers(coordinates).

So depending on the body_id, I want to make an array of objects of the class Body with each object having the name <body_id>, containing the coordinates, BUT I want
to do it on the first reading of the file. I read the string, check if the name is among Body array, if it is I add the new coordinates to the Body object, but if it isn't I want to create a new Body object to the array, how do I do it without making a list?

A std::vector or std::array spring to mind.

vector<Body> theVector;
// make a new Body object here
theVector.push_back(newBodyObject);

Use push_back to keep adding them.

Thank you, I already started implementing the solution with a linked list, but since I have no idea how to use the templates you are suggesting, could you please tell me where I can learn more about them, my C++ knowledge lacks templates.
Thank you :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.