[Insight-developers] When are variables made private vs protected?
Bill Lorensen
bill.lorensen at gmail.com
Fri Dec 2 14:50:06 EST 2011
For the most part, member variables should always be private. They can
be accessed via Set/Get methods. A Get method, in optimized code,
should be as efficient as direct access to the variable. This
separates the implementation of a variable from its access, a form of
information hiding.
On Fri, Dec 2, 2011 at 2:00 PM, David Doria <daviddoria at gmail.com> wrote:
> I am curious how the decision to make member variables private vs
> protected is made. For example, I was trying to derive from
> itkMedianImageFunction and I noticed that the member:
>
> unsigned int m_NeighborhoodRadius;
>
> is private. Therefore, in my subclass, I have to create a new
> member+accessor+mutator for the same purpose. Why would all members in
> ITK not be protected so that they can be more easily subclassed?
>
> Thanks,
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
--
Unpaid intern in BillsBasement at noware dot com
More information about the Insight-developers
mailing list