[C++] Deadlock prevention strategy
\nclass DiningPhilosophers {\n    mutex forks[5];\npublic:\n    void wantsToEat(int philosopher,\n                    function<void()> pickLeftFork,\n          
```\nclass DiningPhilosophers {\n    mutex forks[5];\npublic:\n    void wantsToEat(int philosopher,\n                    function<void()> pickLeftFork,\n                    function<void()> pickRightFork,\n                    function<void()> eat,\n                    function<void()> putLeftFork,\n                    function<void()> putRightFork) {\n          int left = philosopher % 5;\n\t\t\tint right = (philosopher + 1) % 5;\n\t\t\tif (philosopher % 2)\n\t\t\t\tswap(left, right);\n\n\t\t\tlock_guard left_lock(forks[left]);\n\t\t\tlock_guard right_lock(forks[right]);\n        \n\t\t\tpickRightFork();\n\t\t\tpickLeftFork();\n\t\t\teat();\n\t\t\tputLeftFork();\n\t\t\tputRightFork();\n\t }\n};\n```
['C', 'C++']