请问下,c++中front在哪个头文件里

来源:百度知道 编辑:UC知道 时间:2024/04/29 20:35:26
int d(int n,int m)
{
stack<int>x; // must include headline "stack"
x.push(n);x.push(m);
while(1)
{
int y=x.front();
x.pop();
int z=x.front();
x.pop();
if(z%y==0)
return y;
x.push(y);
x.push(z%y);
这是我的代码,包含了一个stack的头文件,但出现以下:
error C2039: 'front' : is not a member of 'stack<int,class std::deque<int,class std::allocator<int> > >'
请问front是哪个头文件里的
谢谢!

钱能书上的吧~
书上错了
不能用front()
用top()就行了
front()不是stack的成员
C++ code:
//=============eg5-6-1===========================
//filename:Recursive_Functions.cpp
//递归函数: 求两个数的最在公约数(递归与消去递归)
//===============================================
#include <iostream>
#include <stack>
using namespace std;
//-----------------------------------------------
long gcd1(int a,int b);
long gcd2(int a,int b);
int gcd3(int a,int b);
//-----------------------------------------------
int main()
{
cout << gcd1(44,121)<<endl
<< gcd2(44,121)<<endl
<< gcd3(44,121)<<endl;
return 0;
}//---------------------------------------------
//法一:递归
long gcd1(int a,int b){
if(a%b==0)
return b;
else return gcd1(b,a%b);
}//---------------------------------------------
//法二:迭代
long gcd2(int a,int b){
for(i