错误答案
#include<stdio.h>
#include<stack>
using namespace std;
class MyQueue(){
stack<int> tem_s;
void push(int x){
while(!data.empty()){
tem_s.push(data.top());
data.pop();
}
tem_s.push(x);
while(!tem_s.empty()){
data.push(tem_s.top());
tem_s.pop();
}
}
int pop(){
data.pop();
}
int top(){
return data.top();
}
bool empty(){
return data.empty();
}
}
int main(){
MyQueue q;
q.push(1);
q.push(2);
q.push(3);
q.push(4);
printf("%d\n",q.top());
q.pop();
printf("%d\n",q.top());
return 0;
}
[Error] expected unqualified-id before ')' token???