求教
struct Node{
int data;
Node * next;
};
class queue
{
public:
queue();
~queue()
{
}
void enqueue( int x);
int dequeue();
int getqueue()
{
if(front!=rear)
return front->next->data;
}
bool isempty();
void print();
private:
Node *front,*rear;
};
queue:: queue()
{
Node * s;
s=new Node;
s->next=NULL;
front=rear=s;
}
void queue::enqueue(int x )
{
Node *s=new Node;
s->data=x;
s->next=NULL;
rear->next=s;
rear=s;
}
int queue::dequeue()
{
if(!isempty())
{
Node *p;
p=front->next;
int x=p->data;
front->next=p->next;
if(p->next=NULL)
rear=front;
delete p;
return x;
}
bool queue::isempty()
{
front==rear?return 1:return 0;
}
void queue::print()
{
if(isempty())
{
cout<<"队列为空"<<endl;
return;
}
Node *p;
p=front->next;
while(p)
{
cout<<p->data;
p=p->next;
}
}
#include<iostream.h>
#include"链式队列.h"
void main()
{
queue b;
for(int i=0;i<10;i++)
b.enqueue(i);
for(int j=0;j<8;j++)
cout<<b.dequeue()<<" "<<endl;
cout<<"出队"<<endl;
cout<<"此时b队列中的元素为"<<endl;
b.print;
}
Compiling...
链式循环队列.cpp
i:\栈\链式队列.h(61) : error C2601: 'isempty' : local function definitions are illegal
i:\栈\链式队列.h(65) : error C2601: 'print' : local function definitions are illegal
i:\栈\链式循环队列.cpp(3) : error C2143: syntax error : missing ';' before 'PCH creation point'
i:\栈\链式循环队列.cpp(4) : error C2143: syntax error : missing ';' before '{'
i:\栈\链式循环队列.cpp(5) : error C2143: syntax error : missing ';' before 'PCH creation point'
i:\栈\链式循环队列.cpp(6) : error C2143: syntax error : missing ';' before 'PCH creation point'
i:\栈\链式循环队列.cpp(7) : error C2143: syntax error : missing ';' before 'PCH creation point'
i:\栈\链式循环队列.cpp(7) : error C2065: 'i' : undeclared identifier
i:\栈\链式循环队列.cpp(7) : warning C4552: '<' : operator has no effect; expected operator with side-effect
i:\栈\链式循环队列.cpp(7) : error C2143: syntax error : missing ';' before ')'
i:\栈\链式循环队列.cpp(11) : error C2143: syntax error : missing ';' before 'PCH creation point'
i:\栈\链式循环队列.cpp(11) : warning C4552: '<' : operator has no effect; expected operator with side-effect
i:\栈\链式循环队列.cpp(11) : error C2143: syntax error : missing ';' before ')'
i:\栈\链式循环队列.cpp(14) : error C2143: syntax error : missing ';' before 'PCH creation point'
i:\栈\链式循环队列.cpp(15) : error C2143: syntax error : missing ';' before 'PCH creation point'
i:\栈\链式循环队列.cpp(16) : error C2143: syntax error : missing ';' before 'PCH creation point'
i:\栈\链式循环队列.cpp(17) : error C2143: syntax error : missing ';' before 'PCH creation point'
i:\栈\链式循环队列.cpp(18) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
链式循环队列.exe - 1 error(s), 0 warning(s)
错在哪了指教