Priority Queue :: C++

This is a discussion on Priority Queue :: C++ within the C++ Programming forums, part of the General Programming Boards category; Hi. Visual C++ .NET outputs this error when I try to declare a priority queue with reverse sorting. ----- // ...

  1. #1
    kuphryn
    Guest

    Priority Queue :: C++

    Hi.

    Visual C++ .NET outputs this error when I try to declare a priority queue with reverse sorting.

    -----
    // Assuming program runs and before I added the following.
    #include <queue>
    #include <functional>

    std:riority_queue<int, std::greater<int>> m_nQueueList;

    // I try this declaration, but receive the exact same
    // error everytime.

    std:riority_queue<int, std::vector<int>, std::greater<int>> m_nQueueList;
    -----

    Here is the error from Visual C++ .NET

    -----
    C2065: 'm_nQueueList' : undeclared identifier
    error C2143: syntax error : missing '>' before ';'
    error C2146: syntax error : missing ',' before identifier 'm_nQueueList'
    error C2208: '<Unknown>' : no members defined using this type
    error C2947: expecting '>' to terminate template-argument-list, found '>>'
    error C2976: 'std:riority_queue' : too few template arguments
    -----

    Does anyone know what the problem is?

    Thanks,
    Kuphryn

  2. #2
    silentstrike
    Guest
    Code:
    std::priority_queue<int, std::vector<int>, std::greater<int>> m_nQueueList;
    does this '>>' look familair? It is being parsed as the left shift operator. You need a space between the two brackets.

    Code:
    std::priority_queue<int, std::vector<int>, std::greater<int> > m_nQueueList;

  3. #3
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    when u post code use the code tags like
    (code)
    your code here
    (/code)

    but instead of ( and ) put [ and ]
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  4. #4
    kuphryn
    Guest
    Okay. Thanks.

    Added a space in between ">>" fixed it.

    Here is the working solution.

    Code:
    std:riority_queue<int, std::vector<int>, std::greater<int> > m_nQueueList;
    I would have never guessed the problem had to do with a missing space. That space operator is tricky.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 08:17 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 02:55 AM
  3. Priority Queue Help
    By cjwenigma in forum C++ Programming
    Replies: 6
    Last Post: 11-14-2007, 11:48 PM
  4. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 09:09 PM
  5. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 11:39 AM

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