65,209
社区成员
发帖
与我相关
我的任务
分享#include <list>
namespace std{
template <typename T, typename A=allocator<T> >
class ilist : public list<T,A>
{
public:
T& operator[](int idx){
iterator it=begin();
for(int i=0; i<idx; i++)
++it;
return *it;
}
const T& operator[](int idx)const{
const_iterator it=begin();
for(int i=0; i<idx; i++)
++it;
return *it;
}
};
}
#include <list>
namespace std{
template <typename T, typename A=allocator<T> >
class ilist : public list<T,A>
{
public:
T& operator[](int idx){
iterator it=begin();
for(int i=0; i<idx; i++)
++it;
return *it;
}
const T& operator[](int idx)const{
iterator it=begin();
for(int i=0; i<idx; i++)
++it;
return *it;
}
};
}