class War {
private:
string place;
list <soldier*> soldiers; // list with pointer soldier for all soldiers
public:
War (){ place = ""; } //
War(ifstream & inn); // constructure to read all data from file
~War (); //??????? I need here to create destructor to delete all soldiers from //the list
};
Without knowing how the elements are created and therefore should be destroyed using a loop based on whether a list is empty isn't a bad choice for clearing a list.
[ETA]: If the list is used to store pointers of objects created on the heap I'd personally use smart pointers over raw pointers & new/delete. That way when the class dtor is called the list's contents are automatically destroyed as well as the class object goes out of scope. No messy details of manual memory management.
The STL <list> is destroyed automatically so doesn't have to be treated or even mentioned in the destructor.
If the elements (whether they are pointers or objects) are to be de-listed then the List::erase() and/or List::clear() functions apply right up to and including the point where List::empty() indicates there are no more elements.
If the elements have been initiated by using 'new' inside or outside the class then they should be considered carefully for getting the normal 'delete' treatment to avoid memory leaks.