I have an assignment for class where I have to implement a linked list and then create the derived classes for stack and queue. The linked list works, but I'm having trouble doing the inheritance for stack and queue. This is sample code of how I've set things up:
I created a nested class called ITERATOR inside the LIST class to imitate the iterators in the STL containers. This works fine:
1 2
LIST<int> mylist;
for (LIST::ITERATOR it = mylist.begin(); it != mylist.end(); it++);
The following gives "error: 'STACK<T>::ITERATOR::ITERATOR(const STACK<T>::ITERATOR&) [with T = int; STACK<T>::ITERATOR = STACK<int>::ITERATOR]' is private" and points to the copy constructor of STACK::ITERATOR.
1 2
STACK<int> mystack;
for (STACK::ITERATOR it = mystack.begin(); it != mystack.end(); it++);
How do I fix this?
EDIT: Figured it out. Keep making stupid mistakes due to lack of sleep. I forgot to put in the access specifiers and before that I had forgotten to put in constructor functions.