我想我该做的都做了,可是还是不行
小弟编了一个队列的类,可是怎么也通不过
程序在bc5.0中调试编译时有6个错误:
undefined symbol 'MaxQSize'
undefined symbol 'MaxQsize'
undefined symbol 'count'
undefined symbol 'front'
undefined symbol 'qlist'
undefined symbol 'MaxQSize'
可是我要做的都做了呀。比如unfefined symbol 'MaxQSize'我在程序中早有了
const int MaxQSzie=50;
至于 count 、front、qlist这是类的成员呀
# include<iostream.h>
# include<stdlib.h>
const int MaxQSzie=50;
typedef int DataType;
class Queue
{
protected:
int front ,rear,count;
DataType qlist[MaxQSzie];
public:
Queue(void);
//改变队列的操作
void QInsert(const DataType & item);
DataType QDelete(void);
void ClearQueue(void);
//访问队列
DataType QFront(void)const;
//检测队列状态
int QLength(void)const;
int QFull(void)const;
int QEmpty(void)const;
} ;
Queue::Queue(void):front(0),rear(0),count(0)
{}
//--------------------------------------------------
void Queue::QInsert(const DataType & item)
{
if(count==MaxQSize)
{cerr<<"Queue overflow!"<<endl;
exit(1);
}
count++;
qlist[rear]=item;
rear=(rear+1)%MaxQSize;
}
//-----------------------------------------------------
//删除对首元素返回其值
DataType Queue::QDelete(void)
{
DataType temp;
if(count==0)
{cerr<<"Deleting from an empty queue!"<<endl;
exit(1);
}
temp=qlist[front];
count--;
front=(front+1)%MaxQSize;
return temp;
}
//--------------------------------------------------------
void Queue::ClearQueue(void)
{front=0;rear=0;count=0;}
//--------------------------------------------------------
DataType QFront(void)
{
if(count==0)
{cerr<<"It's empty!"<<endl;
exit(1);
}
return qlist[front];
}
//---------------------------------------------------------
int Queue::QLength(void)const
{ return count;}
//---------------------------------------------------------
int Queue::QEmpty(void)const
{ return count==0;}
//----------------------------------------------------------
int Queue::QFull(void)const
{ return count==MaxQSize ; }
//===================================================
void main()
{ Queue a;
a.QInsert(3);
a.QInsert(5);
do { cout<<a.QFront()<<endl;
a.QDelete();
}while(!a.QEmpty()) ;
}