-
stacks
I am trying to create a simple stack but the compiler (visual c++ 6.0) is saying that 'stack' is an undelcared identifier. I am keying in the source code directly from a text book. Whats wrong
program:
#include <iostream>
#include <stack>
int main()
{
int n;
double item;
stack<double>numbers; //this is where I get the error 'stack':undelcared identifier
cout<<"type number"<<endl
cin>>n;
for (int i=0; i<n; i++);
{
cin>>item;
numbers.push(item);
}
}
-
stack is in the std namespace. You can either do
using namespace std;
or
using std::stack;
using std::cout;
using std::cin;
//etc
at the top of your code, or prefix each type with std -
std::stack<double>numbers;
//etc