Having class :
template<class T>
class Link
{
Link* myParent_;
Link* myLeft_;
Link* myRight_;
T* myData_;
void assign_(Link<T>*& marker, Link<T>*& aLink);
void insert_(const T&);//inserts new data into a link
void insert_(const T*);
void remove_();//removes data from a link
public:
class Iterator : public iterator<std::bidirectional_iterator_tag, Link<T>*>
{
private:
Link<T>* myData_;//How can I assign object of external class to this link? Rest of the Q below.
public:
Iterator();
Iterator& left()const;
Iterator& right()const;
Iterator& top()const;
};
};
What I mean by that is how can I assign "this" object to myData_ and not myLeft_, myRight_ or myParent_ of "this" object?
I tried something like this:
template<class T>
Link<T>* Link<T>::me() const
{
return const_cast<Link<T>*>(this);
}
and in Iterator:
template<class T>
Link<T>::Iterator::Iterator():myData_(nullptr)
{
myData_ = me();//call from external class to me();
}
but I'm getting an error:
Error 1 error C2352: 'Link::me' : illegal call of non-static member function
Thank you.