is there a way to clear a structure of vectors at a time using a single statement ? i.e. struct AStruct { vector StringList; vector DistanceList; }A;
i want both the vectors using a single statement.
is there a way to clear a structure of vectors at a time using a single statement ? i.e. struct AStruct { vector StringList; vector DistanceList; }A;
i want both the vectors using a single statement.
Sure:
AStruct a;
// stuff
a = AStruct(); // clear it
However, I would probably give myself a function:
struct AStruct {
vector <string> StringList;
vector <string> DistanceList; }
void clear() {
StringList.clear();
DistanceList.clear();
}
};
You can then say:
AStruct a;
// stuff
a.clear(); // clear it
which is perhaps easier to understand.