为什么这样会报错,而改成引用传递就不会报错呢??
//判断栈空,空返回1,非空返回0int stactempty(stack *s)
{
if(s.top==0)
{
cout<<"表是空的!"<<endl;
return 1;
}
else
{
cout<<"表非空!"<<endl;
return 0;
}
}
:\c程序\lab_4_1\stack_array.cpp(63) : error C2228: left of '.top' must have class/struct/union type
Error executing cl.exe.
stack_array.obj - 1 error(s), 0 warning(s)
//定义顺序存储的栈
typedef int typedata;
struct stack_array
{
typedata array;
int top;
};
typedef stack_array stack;
这个是栈,那个打错字了 明白了 应该是 s->top
页:
[1]