1

I'm trying to implement a stack using a linked list, my Node struct is the private data of my ListStack class. When i try and use Node in my main.cpp it says that Node is an undeclared identifier. By the way i'm using this stack and everything to implement a RPN calculator and i have 3 files calculator.h, calculator.cpp, and main.cpp(if that is relevant)

Here is the struct:

struct Node
{
    double data;
    Node* under;
};

Node* top;

I have included the .h file(calculator.h) with #include "calculator.h"

The first statement it doesn't recognize is Node* current= top; it also does not recognize top. Any reason for this? I'm kind of new to this site so sorry if I haven't included enough information.

4

1 回答 1

2

If your structure is a private variable of a class you can't call it like that, you need something like

MyClass::Node mynode;
于 2013-03-10T17:40:10.863 回答