?? stack.h
字號:
template <class T>
struct node
{
T value;
node<T> *next;
};
template <class T>
class stack
{
public:
char Err[35];
node<T> *First;
int Count;
stack(){Count = 0;strcpy(Err,"");First = NULL;}
T Pop()
{
node<T> *tempNode;
T tempVal;
if (First!=NULL)
{
tempVal = First->value;
tempNode = First;
First = First->next;
delete(tempNode);
}
else return NULL;
return tempVal;
}
T front()
{
return First->value;
}
T Value()
{
if (First!=NULL)
{
return First->value;
}
return "";
}
void Push(T v)
{
node<T> *tempNode;
tempNode = new node<T>;
tempNode->value = v;
tempNode->next = First;
First = tempNode;
}
bool Last()
{
if (First!=NULL)
if (First->next==NULL)
return true;
return false;
}
void Empty()
{
T t;
while (First != NULL)
t = Pop();
}
bool isEmpty()
{
if (First != NULL)
return false;
return true;
}
};
template <class T>
void CopyStack(stack<T>& aStack, stack<T>& bStack) //Copy b into a
{
aStack.Empty();
stack<T> temp;
T a;
while (bStack.isEmpty() == false)
temp.Push(bStack.Pop());
while (temp.isEmpty() == false)
{
a = temp.Pop();
bStack.Push(a);
aStack.Push(a);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -