0

For some reason I am having trouble with just returning the address of the data field being pointed to by the node pointer.

template <class T>
        T* Iterator<T>::operator->() const
        {
        return *nodePtr->data;
        }
2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Tom Gunn
1

return *nodePtr->data;

Unless data is a pointer to a pointer, this either returns data or throws an indirection error. To get the address of an object you use the & operator:

return &nodePtr->data;
Votes + Comments
Always get there before others, huh?
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.