T
tragomaskhalos
I'm not intending to make a snyde comment so I apologize if it comes
across that way, but it seems to me that you are arguing for increased
coupling between objects for the sake of saving yourself some key-
strokes. For me, I try and always use the weakest relationship between
objects that I can get away with, not saying this is "the way" just
that is what I try to do.. Since in this example we know that the std
container will not have a) and protected data that I need to use, and
b) the std container contains no virtual functions I need to override
then I will use containment, forwarding functions have never been a
chore to write or get right. If you choose to inherit in this case, it
appears that you would be creating a needless dependency.
Your desire for the weakest relationships is exactly correct I
think, but if you contain a vector and delegate to it, and I inherit
privately from vector and make its operations available via
"using", it seems to me we are *both* tightly coupled to the vector.
However it turns out that Sutter (Exceptional C++ item 15) agrees
with you, and recommends using private inheritance "only when
absolutely necessary". So I'm not going to argue the point, but
I need to digest his and your arguments before I can convince
myself!