2012-11-30 71 views
0

我被赋予和开发手机模拟的任务,其中一部分要求包括使用队列来存储来自txt文件的电话号码以模拟被调用。我已经一遍又一遍地检查,包括#include,但是告诉我“未通过队列”的错误消息仍然显示出来。我正在使用Bloodsehd Dev-C++,并且我已经包含了一个用于测试队列的示例,如果它只是程序没有正确的信息,将不胜感激。我检查了其他网站大多数人说添加#include或#include既不能解决问题。堆栈和队列在Dev-C++中给出错误

#include <queue> 
#include <deque> 
#include <iostream> 
#include <fstream> 
using namespace std; 

class cell 
{ 
    public: 
     cell(); 
     ~cell(); 
     void upload(string item);//Insert in order 
     void printnew();//Print call just recieved 
     void printlater();//Print calls for later 
     int Front(); //returns front element 
     int Rear(); //returns rear element 
     bool Empty(); 

    private: 


}; 

int main() 
{ 
    Queue Q; 
    Q.Enqueue(54); 
    cout << Q.front(); 


    system("Pause"); 
    return 0; 
} 
+1

“队列”与“队列”并不相同......尝试队列问题 –

+0

请更新您的IDE至以下版本,该版本修复了大量错误,并附带GCC 4.6.1或4.7。 0,并且是完全可移植的:http://sourceforge.net/projects/orwelldevcpp/ – Orwell

回答

1

如果你想使用C++标准库queue,您必须声明为

queue<int> Q; 
Q.push(54); 
cout << Q.front(); 
+0

同样谢谢你,这个信息将会有帮助,因为在讲义上没有任何东西可以工作。 – Kreg

+0

队列没有push_back成员 – billz

+0

@billz感谢您的发现,修复。 –

2

要使用STL队列中,则需要:

#include <queue>  // include necessary header 

std::queue<int> q; // initialize queue container with type int 
q.push(54);   // add element to queue 
std::cout << q.front() << std::endl; // access the head of queue 

结帐std::queue参考http://en.cppreference.com/w/cpp/container/queue