class List
{
private:
struct Node
{
int data;
Node* next;
Node(): next(NULL){} //define our own default constructor
Node(int data): next(NULL), data(data){}
};
typedefstruct Node* NodeRef;
NodeRef head;
NodeRef tail;
NodeRef iterator; //points to one node at a time
int size;
I need to write one line of code to return the current element in the list. I think it's done like this?
1 2 3 4
int List::current()
{
return iterator->data;
}
But it keeps giving me an error.
Can I get quick help please?
Thanks
This is means that is a runtime error, and I cannot be certain till I see complete code. It seems that the iterator is not initialised to a valid value before the call to current, from the posted code.