请教在STL里面如何动态生成元素呢?我用new不行啊!!!
#include<iostream>
#include<queue>
#include<string>
using namespace std;
int choice;
void push(queue<int>&),pop(queue<int>&);
void main()
{
string poit;
//p=poit;
queue<int> *q=new queue<int>;
if(q->empty())cout<<"the queue is empth,please input the number"<<endl;
cout<<"Please Input data:";
q->push;
cout<<"the queue is"<<q->size<<endl;
cout<<"you want see the number\yes or no?";
cin>>poit;
if(poit=="no")cout<<"i am sorry!"<<endl;
if(poit=="yes")cout<<"the first number:"<<q->front<<endl;
q->pop;
}
void push(queue<int>& q)
{
while(true)
{
int num;
cin>>num;
if(num==0)break;
cout<<"push a data is"<<num<<endl;
q.push(num);
}
}
void pop(queue<int>& q)
{
while(!q.empty())
{
cout<<"i was delete"<<q.front()<<endl;
q.pop();
}
cout<<endl;
}
if(poit=="yes")cout<<"the first number:"<<q->front<<endl;为什么这句有错呢?请指教.......
我不是很明白啊