C++定义一个容器,包含这四个元素int32_t, std::string, std::string, std::string
时间: 2024-02-23 19:54:28 浏览: 111
C++的string容器
以下是一个C++定义一个容器,包含四个元素的例子:
```cpp
#include <iostream>
#include <vector>
#include <string>
int main() {
std::vector<std::tuple<int32_t, std::string, std::string, std::string>> container;
container.push_back(std::make_tuple(1, "string1", "string2", "string3"));
container.push_back(std::make_tuple(2, "string4", "string5", "string6"));
container.push_back(std::make_tuple(3, "string7", "string8", "string9"));
for (const auto& element : container) {
std::cout << std::get<0>(element) << ", " << std::get<1>(element) << ", "
<< std::get<2>(element) << ", " << std::get<3>(element) << std::endl;
}
return 0;
}
```
输出结果:
```
1, string1, string2, string3
2, string4, string5, string6
3, string7, string8, string9
```
阅读全文