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;
}
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;
}
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;
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.