Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdlib.h>
- #include <algorithm>
- class Renderable
- {
- public:
- Renderable()
- :_priority(0)
- {
- }
- explicit Renderable( unsigned int priority)
- :_priority(priority)
- {
- }
- bool operator< (const Renderable& b);
- void SetPriority( unsigned int priority)
- {
- _priority = priority;
- }
- private:
- unsigned int _priority;
- };
- bool Renderable::operator< (const Renderable& b)
- {
- unsigned int _pri = b._priority;
- return _priority < _pri;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- Renderable foo(67);
- Renderable bar(58);
- bool result = foo < bar;
- Renderable a[10];
- for( int i = 0; i < 10; ++i)
- {
- unsigned int num = rand();
- a[i].SetPriority(num);
- }
- std::sort<Renderable*>(a+0, a+10);
- return 0;
- }
Add Comment
Please, Sign In to add comment