ostream& operator<<(ostream&os,Seqstack &S) //操作重载
ostream&operator<<(ostream&os,Seqstack&S)//操作重载{os<<"top="<<S.top<<endl;for(inti=0;i<...
ostream& operator<<(ostream&os,Seqstack &S) //操作重载
{
os<<"top="<<S.top<<endl;
for (int i=0;i<=S.top;i++)
os<<i<<":"<<S.elements[i] <<endl;
return os;
}
error:
error C2065: 'S' : undeclared identifier
D:\jingyao_Tree\Seqstack.cpp(63) : error C2228: left of '.top' must have class/struct/union type
D:\jingyao_Tree\Seqstack.cpp(64) : error C2228: left of '.top' must have class/struct/union type
D:\jingyao_Tree\Seqstack.cpp(65) : error C2228: left of '.elements' must have class/struct/union type 展开
{
os<<"top="<<S.top<<endl;
for (int i=0;i<=S.top;i++)
os<<i<<":"<<S.elements[i] <<endl;
return os;
}
error:
error C2065: 'S' : undeclared identifier
D:\jingyao_Tree\Seqstack.cpp(63) : error C2228: left of '.top' must have class/struct/union type
D:\jingyao_Tree\Seqstack.cpp(64) : error C2228: left of '.top' must have class/struct/union type
D:\jingyao_Tree\Seqstack.cpp(65) : error C2228: left of '.elements' must have class/struct/union type 展开
1个回答
展开全部
S不是类,结构体,联合。
更多追问追答
追问
class SeqsStack
{
private:
T *elements; //栈元素存放数组
int top; //栈顶指针
int maxsize; //栈最大容量
void overflowProcess(); //栈的溢出处理
public: Seqstack(int sz=50);
~Seqstack(){delete []elements;}
。。。。。。。。
friend ostream &operator<<(ostream &os,Seqstack &S);
};
追答
类名不能识别,如果是类定义和实现分离,记得加上头文件
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询