Re: Code guidelines, state of C++ compilers used, and general C++comments


Subject: Re: Code guidelines, state of C++ compilers used, and general C++comments
From: Mike Nordell (tamlin@algonet.se)
Date: Tue May 09 2000 - 02:13:53 CDT


Leonard Rosenthol wrote:

>At 2:17 AM +0100 5/9/00, Mike Nordell wrote:
>>12. Add: Never EVER put a member variable under any other access
>>specification than private. Derived classes have NO business of probing
>>the baseclass' private parts (pun intended).
>
>I disagree! There are numerous examples of where protected
>member variables are perfectly acceptable and correct. However,
>public members are definitely a bad thing!

I disagree too! :-)

Since you mention "numerous examples", would you care to share at least
two of these "perfectly acceptable and correct" eamples with us?

I've never, ever, seen an occasion where a protected member variable is
acceptable, and I've debugged&fixed quite a few, and designed my share
of, C++ systems.
Just to give a glimpse of the maintenance nightmare we're facing, I found
out that baseclass (protected) member variables got initialized/replaced
by subclasses (in AbiWord). This issue should not be taken lightly, since
e.g. object ownership _do_ become a can of worms.

There's also no way to know what class' member variables you're poking
around with when you see e.g.
  m_pBase = new Derived;
This implies that it's "your" member, but with protected member variables
it might as well be a baseclass waaay up in the hierarchy. This is not
only a matter of evil (tm), it's dangerous.

/Mike - please only post follow-ups to the list



This archive was generated by hypermail 2b25 : Tue May 09 2000 - 01:14:35 CDT