[英]how to access set elements by index like vector?
I have made a code that construct a set of sets.我制作了一个构造一组集合的代码。 However, I want to access set index like vector *(vec.begin()+i).Is it possible like accessing vector?但是,我想访问像向量 *(vec.begin()+i) 这样的集合索引。是否有可能像访问向量一样? I got an error,Please help me, Is there any solution我得到一个错误,请帮助我,有什么解决办法
#include <iostream>
#include <set>
using namespace std;
int main ()
{
int myints[] = {75,23,65,42,13};
std::set<int> myset (myints,myints+5);
std::cout << "myset contains:";
for (int i = 0; i < myset.size(); i++) {
cout<<*(myset.begin()+i);
}
std::cout << '\n';
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.