Thread: stacks

  1. #1

    Angry 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

    #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
    for (int i=0; i<n; i++);


  2. #2
    S­énior Member
    Join Date
    Jan 2002
    stack is in the std namespace. You can either do

    using namespace std;


    using std::stack;
    using std::cout;
    using std::cin;

    at the top of your code, or prefix each type with std -


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help Me With This Code Of Implementing Stacks
    By raghu_equinox in forum C Programming
    Replies: 3
    Last Post: 10-19-2006, 07:22 AM
  2. ...multiplication using stacks
    By iiwhitexb0iii in forum C Programming
    Replies: 1
    Last Post: 10-09-2006, 01:28 AM
  3. Avioding Stacks
    By LoafOfBread34 in forum C++ Programming
    Replies: 8
    Last Post: 12-08-2004, 06:20 AM
  4. Dumping singly linked list into 2 stacks.
    By strotee76 in forum C++ Programming
    Replies: 5
    Last Post: 05-16-2004, 05:48 PM
  5. Stacks stacks stacks
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 06-06-2002, 02:01 AM