thread encapsulation with private attributes

Hi, I was thinking about using boost as much as I could on a proyect. The idea of using the pthread encapsulation ocurred to me. But I found that the interface was pretty poor. I guess it is like that cause of portability. So I thought, ok... I can inherit from it and encapsulate the pthread (thats my case) functioanlity I want. But to my surprise the pthread_t variable called m_thread was declared PRIVATE... why is that?!... I mean... why wouldn't u want somedy to inherit and extend the functionality to the user's will? thanks for clarifying my doubt. Nicolas-

On Thursday 24 May 2007 21:43:06 Nicolas Emiliani wrote:
Hi, I was thinking about using boost as much as I could on a proyect. The idea of using the pthread encapsulation ocurred to me. But I found that the interface was pretty poor.
I wouldn't say so. It is minimalistic, but not poor. What exactly is it that you need? That said, there are quite a few enhancements that could be done and the proposals are also already out there.
I guess it is like that cause of portability. So I thought, ok... I can inherit from it and encapsulate the pthread (thats my case) functioanlity I want. But to my surprise the pthread_t variable called m_thread was declared PRIVATE... why is that?!
...because you are not supposed to mess with the private parts of a class? The principle is called encapsulation and protected member data is bad for it.
... I mean... why wouldn't u want somedy to inherit and extend the functionality to the user's will?
This is drifting in a general C++ question topic but inheritance isn't necessarily used to extend something (you can usually achieve that without derivation) but rather to customize something, i.e. baseclass declares foo() and derived classes implement it in various ways. It is usually a bad idea to allow derived classes access to your members except perhaps in very limited form via accessors because this also opens doors to abuse. Uli
participants (2)
-
Nicolas Emiliani
-
Ulrich Eckhardt