{
if(isEmpty())
return ERROR;
else
e=*--top;
return OK;
}
template <typename ElemType>
void SqStack<ElemType>::push(ElemType& e)
{
int length=top-base;
ElemType *newbase;
if(top-base>=stackSize)
{
newbase=new ElemType[stackSize+STACKINCREMENT];
assert(newbase!=0);
for(int j=0;j<length;j++)
*(newbase+j)=*(base+j);
delete []base;
stackSize+=STACKINCREMENT;
base=newbase;
top=base+length;
}
*top=e;
++top;
}
template <typename ElemType>
SqStack<ElemType>::SqStack()
{
base=new ElemType[STACK_MAX_SIZE];
assert(base!=0);
stackSize=STACK_MAX_SIZE;
top=base;
}
template <typename ElemType>
SqStack<ElemType>::~SqStack()
{
if(base)
delete []base;
stackSize=0;
top=base=NULL;
}
template <typename ElemType>
SqStack<ElemType>::SqStack(const SqStack& otherS)
{
int length;
base=new ElemType[otherS.stackSize];
assert(base!=0);
stackSize=otherS.stackSize;
for(int i=0;i<length;i++)
*(base+i)=*(otherS.base+i);
top=base+length;
}
总是出现这样的错误
ompiling...
q.cpp
f:\microsoft visual studio\myprojects\zhan\q.cpp(10) : error C2146: syntax error : missing ';' before identifier 'getTop'
f:\microsoft visual studio\myprojects\zhan\q.cpp(23) : see reference to class template instantiation 'SqStack<ElemType>' being compiled
f:\microsoft visual studio\myprojects\zhan\q.cpp(10) : error C2501: 'Status' : missing storage-class or type specifiers
f:\microsoft visual studio\myprojects\zhan\q.cpp(23) : see reference to class template instantiation 'SqStack<ElemType>' being compiled
f:\microsoft visual studio\myprojects\zhan\q.cpp(13) : error C2146: syntax error : missing ';' before identifier 'pop'
f:\microsoft visual studio\myprojects\zhan\q.cpp(23) : see reference to class template instantiation 'SqStack<ElemType>' being compiled
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/dianqi/article-52420-2.html
易烊千玺真是好看极了
非也
看来这个狼真的来了