I'm trying to write the delete function of a stack class, and i'm getting the error:
error C2440: '=' : cannot convert from 'struct dataNode *' to 'struct Stack::deleteRec::dateNode *'
Code:class Stack
{ private:
struct dataNode* listPtr;
struct dataNode* endPtr;
int listSize;
bool empty();
public:
Stack();
void insert(struct dataNode*);
void deleteRec();
int size();
void show();
};
void Stack::deleteRec()
{ struct dateNode* nextPtr;
nextPtr = endPtr;
for (int i=0;i<listSize-1;i++)
{ nextPtr = nextPtr->next;
}
delete nextPtr;
listPtr=nextPtr;
listSize--;
}
The error is for the second line of the deleteRec. As far as i can see, endPtr is of an identical type as nextPtr so i dont know why it's complaining, especially as it let me do this in another function above it.
Thanks in advance