In the following program how do i output 'maxelem' and 'top' the cout line is giving me an undefined error..
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
class IntStack
{
public:
IntStack(int num) { top = 0; maxelem = num; s = new int[maxelem]; }
void push(int t)
{
if (top == maxelem) return;
s[top++] = t;
}
int pop()
{
if (top == 0) return -1;
return s[--top];
}
void display()
{
if (top == 0) { cout << "(empty)\n"; return; }
for (int t=0 ; t < top ; t++) cout << s[t] << " ";
cout << "\n";
}
int empty() { return top == 0; }
private:
int *s;
int top;
int maxelem;
};
void main()
{
IntStack *s = new IntStack(100);
int d;
s->push(0);
s->push(10);
s->push(1);
s->push(5);
s->push(4);
s->push(6);
s->push(5);
s->push(9);
s->display();
s->push(6);
s->push(99);
s->push(8);
s->push(55);
s->pop();
cout <<"Depth of stack: " <<maxelem<< ", Max Depth: "<<top;
int wait;
cin >> wait;
}