构造函数
queue<T> queT;//queue 采用模板类实现,queue 对象的默认构造形式:
queue(const queue &que);//拷贝构造函数
赋值操作
queue& operator=(const queue &que);//重载等号操作符
存取 插入 删除
push(elem);//往队尾添加元素
pop();//从队头移除第一个元素
back();//返回最后一个元素
front();//返回第一个元素
大小操作
empty();//判断队列是否为空
size();//返回队列的大小
实例
void test(){
queue<int> q;
q.push(10);
q.push(20);
q.push(30);
q.push(40);
q.push(50);
if(!q.empty())
{
cout<<"容器不为空 size="<<q.size()<<endl;
while(!q.empty())
{
cout<<q.front()<<" "; //10 20 30 40 50
//出队
q.pop();
}
cout<<endl;
}
}
网友评论