is there a way to clear a structure of vectors at a time using a single statement ?开发者_JAVA百科 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.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论