标签: STL

STL vector

#include <vector> using namespace std; 定义vector  vector ListData; 添加元素  ListData.push_back(1); 获取元素数量  ListData.size(); 清空元素  ListData.clear(); 遍历 if (!ListData.empty()) { for (auto ListDataIterator = ListData.begin(); ListDataIterator != ListData.end(); ++ListDataIterator) { // 在这里处理 ListData…

STL vector 逗号分割保存到字符串中

#include <iostream> #include <vector> #include <string> int main() { std::vector<std::string> numbers = {"111", "abc", "123"}; std::string result; for (const auto& num : numbers) { if (!result.empty()) { result += ","; } result += n…