Subj : Re: Challenge: Multithreading & Synchronization To : comp.programming.threads From : Sergei Organov Date : Wed May 18 2005 07:58 pm "Uenal Mutlu" <520001085531-0001@t-online.de> writes: [...] > class Locker > { > public: > Locker(mutex& Am) : m(Am) { m.lock(); } > ~Locker() { m.unlock(); } > private: > mutex& m; > }; > > Locker then can be used for both mutex and rmutex. > This is because rmutex is derived from mutex. Do you understand that it's wrong provided the following definitions from your challenge hold: > // non-recursive mutex: > class mutex > { > public: > mutex() { /*..*/ } > ~mutex() { /*..*/ } > void lock() { /*..*/ } > void unlock() { /*..*/ } > [...] > }; > > // recursive mutex: > class rmutex : public mutex > { > public: > rmutex() { /*..*/ } > }; Do you understand that (public) derivation of rmutex from mutex is broken OO design in the first place? Anyway, why do you mix OO-issues that you don't seem to understand well, C++ issues that you don't seem to understand well, and threads related issues that you don't seem to understand well in a single challenge? -- Sergei. .