STL problem

This is a discussion on STL problem within the C++ Programming forums, part of the General Programming Boards category; I have a problem using STL. When I type the following code into my program: Code: typedef std::multiset<int, std::less<int>> ims; ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    7

    STL problem

    I have a problem using STL. When I type the following code into my program:

    Code:
    typedef std::multiset<int, std::less<int>> ims;
    The following error happens:

    d:\vs 6.0 test\testex34.cpp(8) : error C2146: syntax error : missing ',' before identifier 'ims'
    d:\vs 6.0 test\testex34.cpp(8) : error C2065: 'ims' : undeclared identifier
    d:\vs 6.0 test\testex34.cpp(8) : error C2143: syntax error : missing '>' before ';'
    d:\vs 6.0 test\testex34.cpp(8) : warning C4091: 'typedef ' : ignored on left of 'class std::multiset' when no variable is declared

    I don't understand what seem to be the error. Can you help me? Thank you for your help.

    Note: I am using Microsoft Visual C++ 6.0

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    Add a space between the last two angle brackets:
    Code:
    typedef std::multiset<int, std::less<int> > ims;
    Otherwise the compiler gets confused and parses the line incorrectly.

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,238
    You shouldn't have to specify std::less<int> as a comparator. It's already the default.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Note: I am using Microsoft Visual C++ 6.0
    That particular compiler has serious conformance issues with the standard library. I'd recommend upgrading the library. That won't fix your current problem (yet), but it will sidestep dozens of problems you're likely to encounter.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  2. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  3. STL vector <T> problem
    By correlcj in forum C++ Programming
    Replies: 11
    Last Post: 11-06-2002, 06:18 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21