Hi, I am writing my very first C++ program using classes. I am trying to doit in small steps so I can catch the error early and quick...
I have defined the class, and I tried to place some calls for methods from that class in main. But I get this error: invalid use of 'class Stack'
I've checked what I could, and I really do not know why I get this.
So, my class is defined as such:
What am I doing wrong?Code:/* some includes, namespace std etc. */ class Stack { private: int *ptr; int top; int array[MaxStack]; int tmp; public: void Stack::init() { top = -1; } Stack::Stack() { ptr = new int[MaxStack]; top = 10; ptr = array; for (int i = 0; i < 10; i++) array[i] = 0; } /* some more methods here */ }; int main() { Stack s; s.init(); s.Stack(); /* the line error indicates */ return 0; }