std :: list는 이중 연결 목록입니다. 즉, 반복기에 대한 액세스만으로 목록에서 항목을 제거 할 수 있어야합니다.반복자에 대한 액세스 권한 만 가진 std :: list에서 항목 제거
어쩌면 제 질문이 명확하지 않을 수 있습니다.
#pragma once
#include <list>
typedef std::list<int> IntList ;
typedef IntList::iterator IntIterator;
class IntHiddenList
{
private:
IntList list;
public:
IntIterator AddInt(int x)
{
list.push_front(x);
return list.begin();
}
};
int main()
{
IntHiddenList a;
IntIterator it = a.AddInt(5);
// How would I go about deleting 5 from the list using only "it"?
}
예. 할 수 있습니다. – andre
이제는 질문이 간단 해 보이기 때문에 코드의 일부를 표시하고 수행하려고하는 것을 더 잘 설명 할 수 있습니다. 그러면 원하는 답을 얻지 못할 수도 있습니다. – hetepeperfan
가능하다면 목록의 크기를 업데이트하는 것은 어색 할 것이며위원회는 목록의 크기에 대한 쉬운 액세스를 유지하는 것이 중요한 기능이라고 생각합니다. –