Allen... You may want to reconsider the design. With few exceptions,
protected/public data is discouraged.
// start quote
RESPONSE:
bs@research.att.com (Bjarne Stroustrup), 13 Jun 95
I think that overstates the case against `protected' a bit. here is
the actual quote:
Five years or so later, Mark banned the use of protected data
members in Interviews because they had become a source of bugs:
``novice users poking where they shouldn't in ways that they ought
to have known better than.'' They also seriously complicate
maintenance: ``now it would be nice to change this, do you think
someone out there might have used it?'' Barbara Liskov's OOPSLA
keynote gives a detailed explanation of the theoretical and
practical problems with access control based on the `protected'
notion. In my experience, there have always been alternatives
to placing significant amounts of information in a common base
class for derived classes to use directly. In fact, one of my
concerns about `protected' is exactly that it makes it too easy
to use a common base the way one might sloppily have used global
data.
Fortunately, you don't have to use protected data in C++;
`private' is the default in classes and is usually the better
choice. Note that none of these objections are significant for
protected member functions. I still consider `protected'
a fine way of specifying operations for use in derived classes.
The Design and Evolution of C++, sec13.9.
However, I do consider reliance on protected data a dubious practice
in any language.
// end quote
Regards,
Jeff
I can't make the baseclass version protected because there are times
when
the baseclass can be used by itself.<
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!