本文整理汇总了C++中MyStack::stackTraverse方法的典型用法代码示例。如果您正苦于以下问题:C++ MyStack::stackTraverse方法的具体用法?C++ MyStack::stackTraverse怎么用?C++ MyStack::stackTraverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyStack
的用法示例。
在下文中一共展示了MyStack::stackTraverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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;
}
示例2: main
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;
}