Thread: Using STL List

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    411

    Using STL List

    When I compile this code.

    Code:
    #include <list>
    
    main() {
    
         list <int> numlist;
    
    }

    I get an error, "list is undeclared identifier".

    All the examples of using the list show this to be correct, do I need to download or update my copy of STL or something? Or are there other headers I must include?

    Im using MSVC 6 with SP5


    Any feedback is appreciated.

  2. #2
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    try this:

    Code:
    #include <list>
    
    main() {
    
        std::list <int> numlist;
    
    }
    I usually typdef anything vectors, list and thing which hide in namespace std;
    Couldn't think of anything interesting, cool or funny - sorry.

  3. #3
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    or you could do this:

    Code:
    #include<list>
    
    using std::list;
    
    int main()
    { list<int> numList;
    
      return(0);
    }
    or even:
    Code:
    #include<list>
    using namespace std;
    
    int main()
    { list<int> numList;
    
      return(0);
    }
    those two methods or endo's are all acceptable, your choice just depends on your preference, i personally get sick of doing std::list, std::string, std::vector and the sort so normally just use a using std::.... .
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  3. Simple list code
    By JimpsEd in forum C Programming
    Replies: 1
    Last Post: 05-24-2006, 02:01 PM
  4. instantiated from here: errors...
    By advocation in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2005, 09:01 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM