Skip to content

Instantly share code, notes, and snippets.

/help Secret

Created February 11, 2018 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b2e803357cd676428ae12c7cef0b1b66 to your computer and use it in GitHub Desktop.
Save anonymous/b2e803357cd676428ae12c7cef0b1b66 to your computer and use it in GitHub Desktop.
help
class iterator {
protected:
Node *node;//address of the current node in the set the iterator belongs to
public:
/**
* Empty constructor. Should not be dereferenced.
* Same as MtmSet::end()
*/
iterator() {}
/**
* Constructor of Set iterator
* @param node The node the iterator points to
*/
explicit iterator(Node *node) {}
/**
* Copy constructor
* @param it The iterator to copy
*/
iterator(const iterator &it) {}
/**
* Destructor
*/
~iterator() {}
/**
* Copy assignment operator.
* @param rhs The iterator to copy.
* @return A reference to this iterator.
*/
iterator &operator=(const iterator &rhs) {}
/**
* Dereference operator * .
* Used like dereference of a pointer with * .
* @return A reference of the data in the node the iterator
* points to.
* @throws NodeIsEndException if the iterator doesn't point to
* an element in the set (end())
*/
const Type &operator*() const {}
/**
* Dereference operator -> .
* Used like dereference of a pointer with -> .
* @return A pointer to the data in the node the iterator
* points to.
* C++ use the -> operator on the returned pointer,
* this allows the user to treat the iterator like a pointer.
* @throws NodeIsEndException if the iterator doesn't point to
* an element in the set (end())
*/
const Type *operator->() const {}
/**
* Prefix increment operator (++i)
* @return a reference to the iterator;
* @throws NodeIsEndException if the iterator doesn't point to
* an element in the set (end())
*/
iterator &operator++() {}
/**
* Postfix increment operator (i++)
* @return iterator that points to the same node as this before
* the increment
* @throws NodeIsEndException if the iterator doesn't point to
* an element in the set (end())
*/
iterator operator++(int) {}
/**
* Compare an iterator with const_iterator. (when there is a
* regular iterator on the left.
* @param rhs the right const_iterator.
* @return true if the two iterators point to the same node
*/
bool operator==(const const_iterator &rhs) const {}
/**
* Compare an iterator with const_iterator. (when there is a
* regular iterator on the left.
* @param rhs the right const_iterator.
* @return true if the two iterators don't point to the same node
*/
bool operator!=(const const_iterator &rhs) const {}
friend class const_iterator;
};
class const_iterator {
Node *node;//address of the current node in the set the iterator belongs to
public:
/**
* Empty constructor. Should not be dereferenced.
* Same as MtmSet::end()
*/
const_iterator() {}
/**
* Constructor of Set const_iterator
* @param node The node the const_iterator points to
*/
explicit const_iterator(Node *node) {}
/**
* Copy constructor
* @param it The const_iterator to copy
*/
const_iterator(const const_iterator &it) {}
/**
* Constructor from iterator (not const_iterator)
* Allows casting from iterator to const_iterator
* @param it The iterator to "copy" to a const_iterator
*/
const_iterator(const iterator &it) {}
/**
* Destructor
*/
~const_iterator() {}
/**
* Copy assignment operator.
* @param rhs The iterator to copy.
* @return A reference to this const_iterator.
*/
const_iterator &operator=(const const_iterator &rhs) {}
/**
* Dereference operator * .
* Used like dereference of a pointer with * .
* @return A reference of the data in the node the const_iterator
* points to.
* @throws NodeIsEndException if the iterator doesn't point to
* an element in the set (end())
*/
const Type &operator*() const {}
/**
* Dereference operator -> .
* Used like dereference of a pointer with -> .
* @return A pointer to the data in the node the const_iterator
* points to.
* C++ use the -> operator on the returned pointer,
* this allows the user to treat the const_iterator like a pointer.
* @throws NodeIsEndException if the iterator doesn't point to
* an element in the set (end())
*/
const Type *operator->() const {}
/**
* Prefix increment operator (++i)
* @return a reference to the iterator;
* @throws NodeIsEndException if the iterator doesn't point to
* an element in the set (end())
*/
const_iterator &operator++() {}
/**
* Postfix increment operator (i++)
* @return const_iterator that points to the same node as this
* before the increment
* @throws NodeIsEndException if the iterator doesn't point to
* an element in the set (end())
*/
const_iterator operator++(int) {}
/**
* Compare two const_iterators.
* @param rhs the right const_iterator
* @return true if the two const_iterators point to the same node
*/
bool operator==(const const_iterator &rhs) const {}
/**
* Compare two const_iterators.
* @param rhs the right const_iterator
* @return true if the two const_iterators don't point to the same
* node
*/
bool operator!=(const const_iterator &rhs) const {}
};
This is the line that's giving me the error:
template<class Type>
MtmSet<Type>::const_iterator::const_iterator(const iterator& it) : node(it.node) {} (it says can't access protected node)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment