Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <tchar.h>
- #include <queue>
- //////////////////////////////////////////////////////////////////////////
- class Node
- {
- public:
- Node() {};
- virtual ~Node() {};
- };
- //////////////////////////////////////////////////////////////////////////
- class Sorter
- {
- public:
- Sorter() {};
- inline bool operator()(Node * a, Node * b) const
- {
- return rand() % 1;
- }
- };
- //////////////////////////////////////////////////////////////////////////
- typedef std::priority_queue<Node *, std::vector<Node*>, Sorter> MyPriorityQueue;
- //////////////////////////////////////////////////////////////////////////
- class Traverser
- {
- public:
- Traverser() {};
- virtual ~Traverser() {};
- void test()
- {
- Node * pNode = new Node();
- mDistanceQueue = &MyPriorityQueue(Sorter());
- mDistanceQueue->push(pNode); // падаем тут. MSVS 2005 c включенной /Ox
- Node * node = mDistanceQueue->top(); // или тут, зависит от погоды
- delete pNode;
- }
- private:
- MyPriorityQueue * mDistanceQueue;
- };
- //////////////////////////////////////////////////////////////////////////
- int _tmain(int argc, _TCHAR* argv[])
- {
- Traverser * pNew = new Traverser();
- pNew->test();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement