I have the following class:
<CODE>
class List
{
public:
class Node
{
public:
Node* m_next;
};
class Iterator
{
public:
Node *m_position;
};
class ConstIterator
{
public:
ConstIterator( Node* pos );
Node *m_position;
};
// utility functions
ConstIterator begin() const;
Iterator begin();
// data members
Node* m_head;
};
</CODE>
The problematic implementation of const begin is:
<CODE>
List::ConstIterator
List::begin() const
{
return List::ConstIterator(m_head);
}
</CODE>
This is wrong because it is impossible to convert const List::m_head to just
pointer. My question is how to project class List to use Iterator and
ConstIterator functionality? I know I can use const_cast to remove constant
property from const List::m_head pointer but I think this isn't a good idea.
Thanks