[Insight-users] Why classes attributes should be private in ITK?

Lemeur Yann Yann.Lemeur at stage.cnes.fr
Wed, 14 Apr 2004 17:29:21 +0200


Hi everybody!

I've used ITK for about a month and I wonder why almost all classes variables are private. 
Actually, I have a problem when I want to create a class (class B) which inherit from a mother-class (called class A) in order to change one method (in my case: adding some lines of code to GenerateData() ).
If this method needs to access to class variables which are private (defined in class A), I can't reimplement it in my new class B because variables are private in the mother class A.
I also can't redefine the variables of A with the same name in B! 

The only solution I've found is to write a "sister class" which inherit from the same class as A, and which is the same as A excepted the few changes I want to add.
Does somebody know another solution to make it properly (ie to avoid to rewrite classes which don't change!)
And I also wonder what is the interest to declare all the class variables private?

Thanks!
Yann