Link to home
Start Free TrialLog in
Avatar of reneschy
reneschy

asked on

Why does't this work. faint.........about priority_queue

I save a sample Struct

struct Packet
{
  unsigned int      l_Priority  : 5;       
  unsigned int      CRC        : 8;
 
  bool operator < (Packet* msg) const      
  {
        return l_Priority < msg->l_Priority ;
  }
  bool operator > (Packet* msg) const      
  {                   
        return l_Priority > msg->l_Priority ;
  }
};
in a priority_queue
 typedef std::priority_queue <const Packet*> Msg_Queue;
but it not works!!
I try to excute following test code
      Packet* p1;
      Packet* p2;

      p1 = new Packet();
      p2 = new Packet();

      p1->l_Priority = 1;
      p2->l_Priority = 3;

      if (p1 > p2)
            printf("p1 > p2\n");
      else
            printf("p1 < p2\n");
the result seems always p1 > p2, even though p1->l_Priority < p1->l_Priority
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial