c语言error c2146,为啥会出现error C2146

当前位置:我的异常网» C++ » 为啥会出现error C2146

为啥会出现error C2146

www.myexceptions.net  网友分享于:2013-10-19  浏览:71次

为什么会出现error C2146:

#include

#include

template

class SqStack

{

public:

void clear();

int getLength();

int getstackSize();

Status getTop(ElemType& e);

bool isEmpty();

SqStackoperator=(SqStackrightS);

Status pop(ElemType& e);

void push (ElemType& e);

SqStack();

virtual ~SqStack();

SqStack(const SqStack& otherS);

protected:

ElemType *base;

ElemType *top;

int stackSize;

};

template

void SqStack::clear()

{

base=top;

}

template

int SqStack::getLength()

{

return top-base;

}

template

int SqStack::getstackSize()

{

return SqStackSize;

}

template

Status SqStack::getTop(ElemType& e)

{

if(isEmpty())

return ERROR;

else

e=*(top-1);

return OK;

}

template

bool SqStack::isEmpty()

{

return (top==base?true:false);

}

template

SqStackSqStack::operator =(SqStack rightS)

{

int length=rights.getLength();

if(this!=&rightS)

{

if(stackSize

{

delect[] base;

base=new ElemType[right.stackSize];

assert(base!=0);

stackSize=rightS.stackSize;

}

for(int i=0;i

*(base+1)=*(rightS.base+i)

top=base+length();

}

return *this;

}

template

Status SqStack::pop(ElemType& e)

{

if(isEmpty())

return ERROR;

else

e=*--top;

return OK;

}

template

void SqStack::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

*(newbase+j)=*(base+j);

delete []base;

stackSize+=STACKINCREMENT;

base=newbase;

top=base+length;

}

*top=e;

++top;

}

template

SqStack::SqStack()

{

base=new ElemType[STACK_MAX_SIZE];

assert(base!=0);

stackSize=STACK_MAX_SIZE;

top=base;

}

template

SqStack::~SqStack()

{

if(base)

delete []base;

stackSize=0;

top=base=NULL;

}

template

SqStack::SqStack(const SqStack& otherS)

{

int length;

base=new ElemType[otherS.stackSize];

assert(base!=0);

stackSize=otherS.stackSize;

for(int i=0;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' 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' 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' being compiled

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值