Hey all. I'm trying to learn stack operations and so far, I believe I've gotten push() and pop() down.
I seem to be stuck on copy, however. I cannot get a check for empty to work correctly.
typedef struct _node
{
payload data;
struct _node *prev;
} node;
int main() {
node *rootPtr = NULL;
node *copyPtr = NULL;
payload userInput;
// get user input for adding items to the stack, yada yada yada...
copyPtr = stackCopy(rootPtr,copyPtr);
}
node *stackCopy(node *originalPtr, node *copyPtr)
{
node *tempPtr;
node *tempTop;
payload data;
node *copyStackRev = NULL;
node *copyStackOrg = NULL;
if (copyPtr != NULL) {
while (!copyPtr.empty()) {
copyPtr.pop();
}
}
...
}
I'm getting a compile error stating that "left of '.empty' must have class/struct/union" so I know I'm using the .empty check incorrectly but I don't know what's wrong. I've check around the forum as well as on cplusplus.com and cannot find the issue.