int main (void) { MyStack *pStack = new MyStack(5); pStack->push('a'); pStack->push('e'); pStack->push('i'); pStack->push('o'); pStack->push('u'); //pStack->clearStack(); pStack->stackTraverse(true); char elem = 0; pStack->pop(elem); cout << elem << endl; pStack->stackTraverse(true); cout << pStack -> stackLength() << endl; if(pStack->stackEmpty()){ cout << "栈为空" << endl; } if(pStack->stackFull()){ cout << "栈为满" << endl; } delete pStack; pStack = NULL; return 0; }
int main (void) { char num[] = "0123456789ABCDEF"; MyStack<char> *pStack = new MyStack<char>(50); int N = 10; int mod = 0; while (N != 0) { mod = N % 16; pStack->push(num[mod]); N /= 16; } pStack->stackTraverse(false); cout << endl; delete pStack; pStack = NULL; return 0; }