
为什么会出现error C2146:
#include<stdio.h>
#include<stdlib.h>
template <typename ElemType>
class SqStack
{
public:
void clear();
int getLength();
int getstackSize();
Status getTop(ElemType& e);
bool isEmpty();
SqStack<ElemType>operator=(SqStack<ElemType>rightS);
Status pop(ElemType& e);
void push (ElemType& e);
SqStack();
virtual ~SqStack();
SqStack(const SqStack<ElemType>& otherS);
protected:
ElemType *base;
ElemType *top;
intstackSize;
};
template <typename ElemType>
void SqStack<ElemType>::clear()
{
base=top;
}
template <typename ElemType>
int SqStack<ElemType>::getLength()
{
return top-base;
}
template <typename ElemType>
int SqStack<ElemType>::getstackSize()
{
return SqStackSize;
}
template <typename ElemType>
Status SqStack<ElemType>::getTop(ElemType& e)
{
if(isEmpty())
return ERROR;
else
e=*(top-1);

return OK;
}
template <typename ElemType>
bool SqStack<ElemType>::isEmpty()
{
return (top==base true:false);
}
template <typename ElemType>
SqStack<ElemType>SqStack<ElemType>::operator =(SqStack rightS)
{
int length=rights.getLength();
if(this!=&rightS)
{
if(stackSize<rightS.stackSize)
{
delect[] base;
base=new ElemType[right.stackSize];
assert(base!=0);
stackSize=rightS.stackSize;
}
for(int i=0;i<length;i++)
*(base+1)=*(rightS.base+i)
top=base+length();
}
return *this;
}
template <typename ElemType>
Status SqStack<ElemType>::pop(ElemType& e)
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/dianqi/article-52420-1.html
雷军
就是和韩国都没得比
简单处理